Unified: Fix many translation errors when exprs appear in pattern context - #22473
Draft
asgerf wants to merge 37 commits into
Draft
Unified: Fix many translation errors when exprs appear in pattern context#22473asgerf wants to merge 37 commits into
asgerf wants to merge 37 commits into
Conversation
These can have labels
Also hide the generated union type from the AST classes
Previously these appeared as nested patterns, meaning they only worked in certain contexts. Decompose the nested patterns into two top-level rules.
This rule matches a labelled function-call, but the general rules for labelled exprs and function calls result in the same AST.
Currently many type errors in the output
This commits demonstrates the idea we're going to use in later commits, deliberately only done for one expr type so far.
This worked, but it's nice to have a test for it
Subscript support is deliberately post-poned to a point where we can design an end-to-end solution for it.
| final F::Expr getAnElement() { result = this.getElement(_) } | ||
|
|
||
| /** Gets the node corresponding to the field `modifier`. */ | ||
| final F::Modifier getModifier(int i) { |
This is a result of mapping subscriptCallExpr -> unsupportedNode
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 PR fixes a bunch of issues with the AST mapping, the largest of which has to do with translation of arbitrary expressions that appear in pattern context.
Although the AST from
syntax-syntaxwraps these inexpressionPattern, the expression underneath can contain deeply nested expressions which themselves must be treated as patterns. This means we can't rely on nested pattern-matching and must use context.A challenge when using context is that many kinds of expressions can appear in pattern context, and the rules for each node kind must handle being in a pattern. After several hopeless attempts I think I found a nice way to express this "coercion" in Yeast (see d95f6c6).
This fixes many type error warnings in practice, but not all of them. I had to stop somewhere. I'll open an internal issue discussing what I know about the remaining cases.
The PR also does a few drive-by fixes:
subscriptCallExprtounsupportedNodeas we're explicitly deferring support for it