swift-syntax icon indicating copy to clipboard operation
swift-syntax copied to clipboard

[SwiftLexicalLookup] Add ScopeSyntax conformance for EnumCaseDeclSyntax

Open Ronitsabhaya75 opened this issue 9 months ago • 0 comments

This PR adds ScopeSyntax conformance to EnumCaseDeclSyntax so that name lookup actually works for enum case payloads.

Previously, associated-value parameter names were totally invisible to lookup. I just set it up so a parameter is only in scope for the default-value expressions of parameters that come after it in the same case. It doesn't leak into other cases (e.g. case foo(a: Int), bar(b: Int = a) won't resolve a) and isn't visible outside the enum case declaration at all.

I also added EnumCaseParameterSyntax: IdentifiableSyntax using the same logic as FunctionParameterSyntax, and threw in a few tests to cover the basic forward references and isolation behavior.

Let me know if this approach makes sense or if I should add more tests!

Ronitsabhaya75 avatar Feb 23 '26 17:02 Ronitsabhaya75