Skip to content

Emit native JS Nullish Coalescing operator (??)#136

Draft
theolivenbaum wants to merge 1 commit intomasterfrom
modernize-null-coalescing-13322305318253151803
Draft

Emit native JS Nullish Coalescing operator (??)#136
theolivenbaum wants to merge 1 commit intomasterfrom
modernize-null-coalescing-13322305318253151803

Conversation

@theolivenbaum
Copy link
Copy Markdown
Collaborator

Implemented native emission of the JavaScript Nullish Coalescing operator (??) in BinaryOperatorBlock. This replaces the previous implementation which generated complex ternary expressions with temporary variables (e.g., ($t1 = val, $t1 != null ? $t1 : default)).

This change improves readability and semantic correctness (handling 0, false, "" correctly compared to ||, though H5 handled this previously with explicit null checks).

Verified with new integration tests covering string, nullable types, and side effects. Existing tests passed (with one unrelated known failure).


PR created automatically by Jules for task 13322305318253151803 started by @theolivenbaum

Replaced the verbose temporary variable generation for the null coalescing operator (`??`) with the native JavaScript `??` operator. This simplifies the generated code and aligns with modern JavaScript standards.

Note: The Optional Chaining operator (`?.`) remains rewritten to explicit null checks due to parser limitations in the current compiler architecture.

Co-authored-by: theolivenbaum <8791811+theolivenbaum@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@theolivenbaum theolivenbaum marked this pull request as draft February 12, 2026 23:52
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