Variable assignment is suppressed / swallowed as part of Function call.

Description

If you attempt to assign a value as part of a Function invocation, the assignment is suppressed / swallowed and the attempt to use the value throws an error. You can reproduce this easily:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 <cfscript> values = [ "a", "b" ]; // Control case so that we demonstrate that .first() will return a non-null value // when called multiple times in a row. echo( "Control 1: " & values.first() & "<br />" ); echo( "Control 2: " & values.first() & "<br />" ); // An experiment to see if we can ASSIGN the value AND RETURN it from an expression // at the same time. echo( "Experiment 1: " & ( temp = values.first() ) & "<br />" ); // Another experiment to see if we an ASSIGN the value AND PASS IT into a function // call at the same time. // -- // CAUTION: This is the BUG! This SHOULD return "False" since the value is defined. echo( "Experiment 2: " & isNull( temp = values.first() ) & "<br />" ); // ------------------------------------------------------------------------------- // // ------------------------------------------------------------------------------- // // NOTE: I am using a UDF wrapper for isNull() because if I try to use isNull() // directly in this experiment, I get the following error: // -- // missing required argument [object] for function [isnull] // -- // For some reason, this issue is side-stepped if I wrap the isNull() call inside of // a custom function. public boolean function isNullWrapper( any value ) { return( isNull( value ) ); } </cfscript>

I have also documented this and the output of the above snippet here: https://www.bennadel.com/blog/3662-possible-bug-variable-assignment-gets-swallowed-by-function-invocation-in-lucee-5-3-2-77.htm

Environment

I'm using Lucee 5.3.2.77 as part of CommandBox.

Status

Assignee

Unassigned

Reporter

Ben Nadel

Labels

None

Affects versions

5.3.2.77

Priority

New