Skip to content

fix(compiler): preserve optional-chain continuations and receivers - #220

Merged
metaphorics merged 2 commits into
stabilize/lsp-framingfrom
stabilize/optional-chain-continuations
Sep 21, 2026
Merged

metaphorics merged 2 commits into
stabilize/lsp-framingfrom
stabilize/optional-chain-continuations

Conversation

@metaphorics

Copy link
Copy Markdown
Collaborator

Change

Route nullish exits past an entire optional chain, including computed keys, following calls, non-null assertions, and delete operations. Preserve the receiver through parenthesized optional method calls. Replace separate member/call lowering paths with one chain-reference mechanism.

Evidence

The committed strict TypeScript fixture was compiled by TypeScript 7.0.2 and executed by Node 24.18.0. Before the fix, null chains performed four forbidden side effects and a grouped method lost its receiver. Both JIT and AOT now match the reference output.

  • All 142 lowering tests pass, including const-enum rejection guards.
  • Full bamts-cli crate passes, including all 51 CLI integration tests.
  • Compiler/CLI all-target clippy with warnings denied passes.
  • Formatting and diff whitespace checks pass.

Stack

Depends on #219; follows merged #217. Refs #157.

Known residuals

The checker can still report BAMTS-C064 for a valid optional-chain indexed access. This PR fixes execution semantics, not full checker compatibility or formal release admission.

Post-Deploy Monitoring & Validation

Owner: repository maintainers. Run the committed optional-chain regression and full CLI suite on the first CI run after integration. Healthy: exact oracle output and no existing regressions. Any output mismatch or const-enum regression blocks integration and triggers reverting this commit.

@coderabbitai

coderabbitai Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: fe3fec09-1289-4341-b355-e3a3c0586ca2

📥 Commits

Reviewing files that changed from the base of the PR and between 787d663 and 035db4e.

📒 Files selected for processing (3)
  • crates/bamts-cli/tests/cli.rs
  • crates/bamts-cli/tests/fixtures/optional-chain-continuations.ts
  • crates/bamts-compiler/src/lower.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-20T08:03:10.841169Z 035db4e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR adds proper parenthesization handling for optional chain expressions when followed by call expressions. The change correctly extends the needs_parens logic to include CallExpression as a parent case, ensuring proper formatting precedence. The implementation is well-tested with comprehensive fixtures covering various optional chaining scenarios.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@metaphorics
metaphorics added this pull request to stack #227 September 20, 2026 21:26
@metaphorics
metaphorics added this pull request to the merge queue Sep 21, 2026
Merged via the queue into main with commit 8a6f2ec Sep 21, 2026
10 of 15 checks passed
@metaphorics
metaphorics deleted the stabilize/optional-chain-continuations branch September 21, 2026 14:23
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