Skip to content

LexerNoViableAltException but script still runs #5832

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

Open
awgymer opened this issue Mar 1, 2025 · 4 comments
Open

LexerNoViableAltException but script still runs #5832

awgymer opened this issue Mar 1, 2025 · 4 comments

Comments

@awgymer
Copy link

awgymer commented Mar 1, 2025

Bug report

I am playing around with the syntax trying to understand the language server better and I managed to generate a possible lexical error in nextflow which shows an error but still runs as the user might expect. Unclear whether this is actually a bug, edge-case, or something else

Expected behavior and actual behavior

Either the script doesn't compile, or the error is not raised.

Steps to reproduce the problem

x = [z: 4]

println "$x\ some more"

Note the space after the \.

Using a \ produces a script compilation error with cause: Unexpected character: '"' in the following other cases:

"a\ b"
"\ a"
"a \ "
" \ a"

Program output

N E X T F L O W   ~  version 24.10.3

Launching `./test.nf` [backstabbing_maxwell] DSL2 - revision: 008f33b6cc

unknown recognition error type: groovyjarjarantlr4.v4.runtime.LexerNoViableAltException
[z:4] some more

Environment

  • Nextflow version: 24.10.3
  • Java version: openjdk version "17.0.10" 2024-01-16
  • Operating system: macOS
  • Bash version: GNU bash, version 3.2.57
@bentsherman
Copy link
Member

This error is very deep, it's coming from ANTLR: https://github.com/tunnelvisionlabs/antlr4/blob/master/runtime/Java/src/org/antlr/v4/runtime/DefaultErrorStrategy.java#L148

I have never figured out why it happens or if/when it's a problem. I just added a warning for it here in the docs. Interesting to see that it can happen with other kinds of escapes.

@awgymer
Copy link
Author

awgymer commented Mar 4, 2025

Yeah it's kind of bizarre, it gets thrown by groovyc too but obviously still compiles and runs "fine" (at least in these cases, I guess its an issue for nextflow multiline bash code in the script section?).

@bentsherman
Copy link
Member

bentsherman commented Mar 4, 2025

I think ANTLR encounters a parsing error, then encounters an error while trying to report the parsing error, and so no error gets reported 😅

But you said it later reports an Unexpected character: '"' error right? So where does that come from?

@awgymer
Copy link
Author

awgymer commented Mar 4, 2025

That report (for unexpected ") is a different compilation error that actually causes failure to compile and it doesn't happen when you have \ (slash space).

The slash-space case is weird because it prints that error but ultimately compiles and runs

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