Skip to content

fix: propagate ?. optional chaining to method call nodes in native parser#144

Merged
cs01 merged 1 commit intomainfrom
fix-optional-chain
Mar 9, 2026
Merged

fix: propagate ?. optional chaining to method call nodes in native parser#144
cs01 merged 1 commit intomainfrom
fix-optional-chain

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Mar 9, 2026

Summary

  • The native parser (parser-native/transformer.ts) never propagated ?. from member expressions to MethodCallNode.optional, causing the native compiler to skip null-check branching for all obj?.method() calls
  • This was the root cause of the "if-drop" bug — the dropped optcall null-check blocks caused IR divergence between JS and native compilers (956 out of 2036 functions differed), leading to self-hosting failures
  • Added loc and optional fields to all MethodCallNode creation sites in the native parser for consistent struct layout

Test plan

  • New test fixture classes/optional-method-call.ts verifies ?. returns null when object is null
  • All 437 tests pass
  • verify:quick passes (Stage 0 + Stage 1 self-hosting)

🤖 Generated with Claude Code

@cs01 cs01 merged commit ce32c29 into main Mar 9, 2026
12 checks passed
@cs01 cs01 deleted the fix-optional-chain branch March 12, 2026 05:34
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