Skip to content

Report generic error for a script definition without a body - #7712

Closed
jorgee wants to merge 1 commit into
invalid-def-syntax-errorfrom
invalid-def-syntax-error-no-body
Closed

jorgee wants to merge 1 commit into
invalid-def-syntax-errorfrom
invalid-def-syntax-error-no-body

Conversation

@jorgee

@jorgee jorgee commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Stacked on #7675. It fixes one case from the review.

Problem: a definition with no body, e.g. process foo, is parsed as a call process(foo). The re-parse then fails on the first token after the statement. So the error points at unrelated code:

Input #7675 This PR
process foo, then workflow { at line 3 3:1 Unexpected input: 'workflow' 1:1 Invalid process definition -- ...
process foo as the last line (line 4) 5:1 Unexpected input: '<EOF>' 4:1 Invalid process definition -- ...

This is a common state while typing in the editor.

Fix: in reparseScriptDeclaration, ignore errors whose offending token is past the end of the statement, and fall back to the generic error. Errors inside the statement are unchanged, including the Unexpected input: '}' case for a missing section. The method now returns whether an error was actually reported, not whether the parse was cancelled.

Test: should report a generic error for a definition without a body in ScriptAstBuilderTest. It fails on #7675 (Unexpected input: 'workflow' @ line 3) and passes with this change. All :nf-lang:test tests pass, plus ScriptDslTest and WorkflowDefTest.

🤖 Generated with Claude Code

When a definition has no body (e.g. `process foo`), the re-parse fails
on the first token after the statement, so the error pointed at the next
definition or past the end of the file. Ignore re-parse errors past the
end of the statement and fall back to the generic error.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: jorgee <jorge.ejarque@seqera.io>
@jorgee
jorgee marked this pull request as ready for review September 29, 2026 12:42
@jorgee
jorgee requested a review from a team as a code owner September 29, 2026 12:42
@jorgee
jorgee requested a review from bentsherman September 29, 2026 13:20
@bentsherman
bentsherman deleted the invalid-def-syntax-error-no-body branch September 29, 2026 15:14
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

Successfully merging this pull request may close these issues.

2 participants