Skip to content

Conversation

beccadax
Copy link
Contributor

This PR adds support for module selectors to the legacy parser and also updates ASTGen to lower the module selector-related syntax nodes introduced by swiftlang/swift-syntax#3091. Although the compiler parses module selectors with this PR, they don't have any actual effect on name lookup or other compiler behavior.

Makes progress on rdar://problem/19481048. Extracted from #34556. Currently under review as SE-0491.

Try to avoid calling `getSourceRange()` on a decl where that will form an invalid range.
When closing paren is missing, point at the location where it should be found, not the opening paren.
A PatternBindingEntry formed from a MissingPatternSyntax has no valid SourceLocs in it, and a PatternBindingDecl containing only PatternBindingEntries with no valid SourceLocs trips an assertion during availability checking. (Generating dummy SourceLocs can cause invalid overlaps between AvailabilityScopes, so that’s not a workable solution.) The fix is to:

• Refuse to generate a PatternBindingEntry from a PatternBindingSyntax with a MissingPatternSyntax (MissingPatternSyntaxes at nested positions don’t have this problem)
• Refuse to generate a PatternBindingDecl with no PatternBindingEntries

This ensures that the invalid AST nodes are never formed.

No current test cases hit this problem, but certain invalid module selector tests can run into this situation when run with ASTGen.
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.

1 participant