Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect error in line 0 when CFML parsing encounters cfscript-like not-equals #230

Closed
mpaluchowski opened this issue Jan 2, 2017 · 5 comments

Comments

@mpaluchowski
Copy link
Contributor

mpaluchowski commented Jan 2, 2017

When scanning the following piece of code:

<cfif "foo" <> "bar">Foo</cfif>

The <> triggers a parsing error (which might be an issue in itself -- I'm not sure if today's standards allow script-like use of comparators in CFML; Update: the code does work correctly on Railo 4.2.), which erroneously appears twice in the report output, once correctly with reported line 1, once incorrectly with line 0:

$ java -jar CFLint-0.11.1-all.jar -file cfml-test.cfm -text
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
line 1:7 no viable alternative at input '"foo"<'
Error in: <cfif "foo" <> "bar">Foo</cfif> @ 1:
expression is null, parsing error
Issue
Severity:ERROR
Message code:PARSE_ERROR
        File:C:\Inbox\cflint-test\cfml-test.cfm
        Column:8
        Line:1
                Message:Unable to parse
                Variable:'null' in function:
                Expression:no viable alternative at input '"foo"<'

Severity:ERROR
Message code:PARSE_ERROR
        File:C:\Inbox\cflint-test\cfml-test.cfm
        Column:0
        Line:0
                Message:Unable to parse
                Variable:'null' in function: null
                Expression:
@ryaneberly
Copy link
Contributor

@mpaluchowski

This is an interesting parsing ambiguity.

Is the following also valid?

<cfif "foo" > "bar">Foo
<cfif "foo" >= "bar">Foo

Determining the correctly way to parse that is not trivial....

@ryaneberly
Copy link
Contributor

image

@ryaneberly
Copy link
Contributor

Lucee 5 seems to parse it though. Very odd. I would suggest that trying to use this edgy syntax is a bad idea.

@mpaluchowski
Copy link
Contributor Author

I'm fine if this triggers a PARSE_ERROR, but can we have just 1 such error reported and on a valid line? In other words: can we remove the one reported for "line 0"? :) We're feeding these results into SonarQube and this fails now because SonarQube (rightly) reports an invalid line number.

ryaneberly added a commit that referenced this issue Jan 6, 2017
only show the first parsing error, not the 2nd with line0
@ryaneberly
Copy link
Contributor

That helps. I agree that the 2nd parsing error should not occur. it is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants