Skip to content

[P1][dsl] report unclosed when...of blocks at EOF #60

Description

@redpeacock78

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions