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

Simple syntax error not reported by report_file #584

Closed
stemann opened this issue Dec 18, 2023 · 2 comments
Closed

Simple syntax error not reported by report_file #584

stemann opened this issue Dec 18, 2023 · 2 comments

Comments

@stemann
Copy link

stemann commented Dec 18, 2023

The simple syntax error ("is") in elseif is Sys.iswindows(platform) was not caught by report_file using JET v0.8.20 on Julia v1.9.3:

function is_supported(platform)
    if Sys.islinux(platform)
        return arch(platform) in ["x86_64", "aarch64", "powerpc64le"]
    elseif is Sys.iswindows(platform)
        return false
    else
        return false    
    end
end

Is this expected?

@aviatesk
Copy link
Owner

It's expected, since your code is actually a valid Julia program.

    elseif is Sys.iswidows(platform)
        return false

is equivalent to

    elseif is
        Sys.iswindows(platform)
        return false

@stemann
Copy link
Author

stemann commented Dec 20, 2023

... but shouldn't the is symbol then be reported as not being defined...?

... a "few" minutes later... :-)

To answer my own question: JET.report_file reports concrete errors - a function definition (even with syntax errors) is not checked in that regard: This reports no errors:

function is_true(foo)
    if foo
        return true
    elseif is foo
        return false
    end
end

Whereas, this reports "is is not defined" (due to the concrete is_true(false) call):

function is_true(foo)
    if foo
        return true
    elseif is foo
        return false
    end
end

is_true(false)

On the contrary, if the function definition had been in a package, JET.report_package (and StaticLint) would report the error (and so would JET.report_file(...; analyze_from_definitions = true)).

@stemann stemann changed the title Simple syntax error not reported if inside conditional Simple syntax error not reported by report_file Dec 20, 2023
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