Repository navigation
Fix a compiler exception - #463
Merged
Merged
Conversation
cpurdy
approved these changes
May 17, 2026
cpurdy
left a comment
Collaborator
There was a problem hiding this comment.
Looks like a reasonable solution to avoid the exception. Are there still any remaining cases where we should be able to resolve something but don't?
lagergren
added a commit
that referenced
this pull request
May 23, 2026
…ls in expression position
Closes two grammar gaps that surface as parse errors against the
manualTests corpus (CI hides these on master because the validation
step is gated on path-filter `lang/**`):
* annos.x:141 — `annotation Foo(...) into Bar { ... }` inside a method
body. Local class/interface/mixin/service declarations were already in
the `_statement` choice; `annotation_declaration` was not. Added.
* generics.x:27 — `Base<Int>.Child2<String>` as a value-position type
literal. `member_type` was reachable from `_non_bi_type` only, so it
was never tried in expression position. Added to `_expression` next
to `$.generic_type` (the symmetric case for non-virtual-child type
literals).
The with-type-arguments form of `member_type` is split into its own
alternative at `prec.left(MAX_PRECEDENCE_PLUS_3)` so it outranks
`member_expression` (MAX_PRECEDENCE_PLUS_2). Without that, the GLR
conflict resolver preferred `member_expression(Base<Int>, Child2)`
and choked on the trailing `<String>`. The no-arguments form keeps
default precedence so `Base<Int>.Child` still parses as a
`member_expression` (no AST shape change for that case).
The previously-declared `[$.member_type, $._expression]` GLR conflict
is now redundant (static precedence resolves the ambiguity) and was
removed; tree-sitter flagged it as an unnecessary conflict.
Why this regressed silently
---------------------------
Neither failure is a tooling/grammar regression — both are new XTC
syntax patterns added to the manualTests corpus that the grammar
never had a test case for:
* generics.x:27 was added on 2026-05-06 by 0120712 ("Fix
NameExpression code production for parameterized virtual child
classes") — a compiler bugfix that needed a test exercising
`Base<Int>.Child2<String>`.
* annos.x:141 was added on 2026-05-17 by 91f6d7d ("Fix a compiler
exception (#463)") — a compiler bugfix that needed a test exercising
a local `annotation … into …` declaration.
Both PRs only touched `manualTests/src/main/x/` and `javatools/`,
never `lang/`. The `dorny/paths-filter` gate in
`.github/workflows/commit.yml` skips the tree-sitter validation step
whenever no `lang/**` paths change, so the master CI run was green
even though both new test files would have failed grammar validation.
This PR (which touches `lang/vscode-extension/**`) is the first since
May 6 to trip the gate and run the validation, which is why both
failures surfaced together here.
The skip lists (parked.txt, intentional.txt) and the grammar template
itself were unchanged between PR #452 (May 1, last grammar work) and
the May 6 / May 17 corpus additions — git log confirms generics.x was
never in any skip list, so the parked.txt header comment "generics.x
parses cleanly now -- removed from this list" is incidentally
misleading; it refers to a draft state that never made it into git.
Verified: `:lang:tree-sitter:testTreeSitterParse` 881/881 (was 879/881),
`:lang:lsp-server:test -Plsp.adapter=treesitter` green,
`validateTreeSitterGrammar` no warnings.
Merged
lagergren
added a commit
that referenced
this pull request
May 23, 2026
…ls in expression position
Closes two grammar gaps that surface as parse errors against the
manualTests corpus (CI hides these on master because the validation
step is gated on path-filter `lang/**`):
* annos.x:141 — `annotation Foo(...) into Bar { ... }` inside a method
body. Local class/interface/mixin/service declarations were already in
the `_statement` choice; `annotation_declaration` was not. Added.
* generics.x:27 — `Base<Int>.Child2<String>` as a value-position type
literal. `member_type` was reachable from `_non_bi_type` only, so it
was never tried in expression position. Added to `_expression` next
to `$.generic_type` (the symmetric case for non-virtual-child type
literals).
The with-type-arguments form of `member_type` is split into its own
alternative at `prec.left(MAX_PRECEDENCE_PLUS_3)` so it outranks
`member_expression` (MAX_PRECEDENCE_PLUS_2). Without that, the GLR
conflict resolver preferred `member_expression(Base<Int>, Child2)`
and choked on the trailing `<String>`. The no-arguments form keeps
default precedence so `Base<Int>.Child` still parses as a
`member_expression` (no AST shape change for that case).
The previously-declared `[$.member_type, $._expression]` GLR conflict
is now redundant (static precedence resolves the ambiguity) and was
removed; tree-sitter flagged it as an unnecessary conflict.
Why this regressed silently
---------------------------
Neither failure is a tooling/grammar regression — both are new XTC
syntax patterns added to the manualTests corpus that the grammar
never had a test case for:
* generics.x:27 was added on 2026-05-06 by 0120712 ("Fix
NameExpression code production for parameterized virtual child
classes") — a compiler bugfix that needed a test exercising
`Base<Int>.Child2<String>`.
* annos.x:141 was added on 2026-05-17 by 91f6d7d ("Fix a compiler
exception (#463)") — a compiler bugfix that needed a test exercising
a local `annotation … into …` declaration.
Both PRs only touched `manualTests/src/main/x/` and `javatools/`,
never `lang/`. The `dorny/paths-filter` gate in
`.github/workflows/commit.yml` skips the tree-sitter validation step
whenever no `lang/**` paths change, so the master CI run was green
even though both new test files would have failed grammar validation.
This PR (which touches `lang/vscode-extension/**`) is the first since
May 6 to trip the gate and run the validation, which is why both
failures surfaced together here.
The skip lists (parked.txt, intentional.txt) and the grammar template
itself were unchanged between PR #452 (May 1, last grammar work) and
the May 6 / May 17 corpus additions — git log confirms generics.x was
never in any skip list, so the parked.txt header comment "generics.x
parses cleanly now -- removed from this list" is incidentally
misleading; it refers to a draft state that never made it into git.
Verified: `:lang:tree-sitter:testTreeSitterParse` 881/881 (was 879/881),
`:lang:lsp-server:test -Plsp.adapter=treesitter` green,
`validateTreeSitterGrammar` no warnings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This issues was reported by Dima on Discord.
The gist of the problem lies in the flow of processing by the StageManager:
during the "resolveName" stage, we resolve all the names with a possible exception of the annotation parameters, since they could be represented by expressions and need to be "validated"
during the "validateContent" stage, we validate those "left behind" annotation parameters; if detect that some of them are on not-yet-validated, we repeat the cycle via
mgr.requestRevisit()APIThe problem arises when the validation requires using the TypeInfo for classes that depend on those "not-yet-validated" ones. In that case, the
UnresolvedNameConstantorUnresolvedTypeConstantwould throw anUnsupportedOperationException, causing the compiler termination.The proposed fix replaces the
UnsupportedOperationExceptionwith theCompilerExceptionand handles it in theStageManagerin the same way a standard "Name not resolved" error