Strange syntax behavior

image

Shouldn’t this syntax throw an exception?

Is it a bug?

Lucee last version

Hmm, this is valid syntax:

foo = bar = 'baz';

and it sets both the foo and the bar variables. I’ve never seen it in a struct literal before. It’s not setting both key names, so it certainly doesn’t seem quite correct. The trailing comma is invalid IMO but it’s something the Lucee parser has always allowed.

2 Likes

The code literally (and I am not a CFNINJA like @bdw429s )

you are calling a value by reference of a value. Lucee is treating it like an alias, versus a second structure item.

utils = { 'one' = 'two' = 'three', }; dump(utils);

I am sure if you grabbed the compiled java and de-compiled it you would see the code as nothing more than java referencing the same string by alias.

To me, it seems really cool that you can do this as AFC would throw an error.

2 Likes

Terry loves perl, Terry loves perl!

sorry, couldn’t resist!

2 Likes

Its the year 2K and active perl all the way!!!
or was that PHP4…

:wink: