Summary
The desugar entry point checks for unclosed function bodies at EOF, but when...of collection also needs an explicit EOF diagnostic. Otherwise an unfinished when block can produce confusing output or secondary errors.
Evidence
dsl/desugar.awk has a global EOF check for _DS_in_function.
dsl/desugar_match.awk owns _DS_in_match state and emits only when it sees end.
- The DSL advertises
when...of as a core feature, so parse errors here should be first-class and line-aware.
Impact
A missing end in a handler can be a common authoring mistake. Without a targeted error, users may see misleading generated AWK output or downstream syntax errors rather than the real DSL problem.
Suggested fix
- In
END, if _DS_in_match is true, report an unclosed when...of error.
- Track the starting line of the
when block to point diagnostics at the correct source location.
- Include a hint like
add an end to close the when...of block.
Acceptance criteria
- Missing
end after when ... of fails desugar with a clear error.
- Error includes source file and useful line context.
- Nested/nearby function close cases are covered by tests.
Priority: P1
Area: dsl/desugar
Type: bug
Summary
The desugar entry point checks for unclosed function bodies at EOF, but
when...ofcollection also needs an explicit EOF diagnostic. Otherwise an unfinishedwhenblock can produce confusing output or secondary errors.Evidence
dsl/desugar.awkhas a global EOF check for_DS_in_function.dsl/desugar_match.awkowns_DS_in_matchstate and emits only when it seesend.when...ofas a core feature, so parse errors here should be first-class and line-aware.Impact
A missing
endin a handler can be a common authoring mistake. Without a targeted error, users may see misleading generated AWK output or downstream syntax errors rather than the real DSL problem.Suggested fix
END, if_DS_in_matchis true, report an unclosedwhen...oferror.whenblock to point diagnostics at the correct source location.add an end to close the when...of block.Acceptance criteria
endafterwhen ... offails desugar with a clear error.Priority: P1
Area: dsl/desugar
Type: bug