Skip to content

Conversation

@zharinov
Copy link
Member

@zharinov zharinov commented Jan 5, 2026

Summary

  • Add Expr::Ref to inner_creates_scope() check in type inference
  • Captured refs like (B) @b now correctly create scope boundaries
  • Fixes type mismatch where @b was inferred as Node instead of B's return type

Why

When a ref is captured ((B) @b), the capture should contain B's structured result, not bubble B's internal captures. This matches the behavior of captured sequences/alternations.

Before: A = (program (B) @b) where B = (expr) @xA = { b: Node, x: Node } (wrong)
After: A = { b: B } where B = { x: Node } (correct)

Uncaptured refs remain transparent - their captures still bubble up correctly.

@zharinov zharinov force-pushed the fix/captured-ref-scope branch from 41fc1cf to 74b7f40 Compare January 5, 2026 03:42
@zharinov zharinov enabled auto-merge (squash) January 5, 2026 03:43
@zharinov zharinov merged commit 963f773 into master Jan 5, 2026
4 checks passed
@zharinov zharinov deleted the fix/captured-ref-scope branch January 5, 2026 03:44
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.

2 participants