CFML parsing bug with `continue`

Description

Reproducing this from Slack.

Repro:

i=1 do { x = randRange(1,10) if (x > 5) { continue } writeOutput(x) } while(++i <= 10)

Error on Lucee: Syntax Error, Invalid Construct

If one puts a semi-colon after the continue, it works. It works as one would expect on CF.

https://trycf.com/gist/063a476b5ab7d0e67300fab8e2e55802/lucee5?theme=monokai

I know continue can take a label. But the label can't start with a }. Looks to me like it doesn't occur to Lucee that } can be considered the end of the previous statement, as much as ; could be, so there might (?) be broader issue here. Although I hasten to add that cfcontinue does NOT need a semicolon, in the same situation.

Not a big deal to me - but figured you should know / it should be searchable if it happens for anyone else.

Environment

None

Activity

Show:

Michael Offner 30 April 2024 at 12:29

As pointed out, ACF maybe uses “}“ to detect the end for that expression as we see with this example.

<cfscript> i=1 do { x = randRange(1,10) if (x > 5) continue writeOutput(x) } while(++i <= 10) </cfscript>

https://trycf.com/gist/32e77522cf729115215499615bc94def/acf2023?theme=monokai

When i run this with ACF i get “Could Not find the Label writeOutput. on line -1“ , so really just a half backed solution. you could argue half backed is better than raw, but i’m not really sure about that.

You can also argue that “continue” (and “break”) not supporting new line for the end of the expression, is also a half baked solution.

The Lucee parser never depends on the context of parent expressions for parsing, changing the parser to do so, is a big change with big risks of regression.

Pothys - MitrahSoft 30 January 2024 at 06:18

I've added a testcase to this ticket.
Pull Request (6.0) : https://github.com/lucee/Lucee/pull/2300 (disabled).

Pothys - MitrahSoft 16 November 2022 at 05:56

I’ve checked this ticket and confirmed the issue happened on the lucee latest version 5.3.10.93-SNAPSHOT. continue without a semicolon inside the script doesn't work in lucee. Seems it works in ACF.

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 11 November 2022 at 13:01
Updated 1 May 2024 at 06:51

Flag notifications