Emit type-matched na sentinels on bare-na reassignment#55
Merged
Conversation
A Pine `x := na` reassignment lowered as `x = na<double>();` for every LHS type. Assigning NaN into an int/int64/bool member is UB: on ARM64 FCVTZS(NaN) yields 0, silently destroying the na sentinel (is_na stays false forever), while x86-64's CVTTSD2SI(NaN) coincidentally lands on INT64_MIN — the sentinel value — masking the bug on that platform. Exemplar: a daily session-open timer (int64, reset to na each new day) never re-armed on ARM64, permanently disabling an open-suppression gate and emitting phantom session-open entries. The constructor-initializer path already re-typed bare na to the member type; the two `:=` lowering sites and the function-var-init block did not. A new resolver returns the declared scalar type (int / int64_t with the epoch promotion / bool / string; None for double, collections, UDTs, and drawing types, which keep their current lowering), gated on the RHS being exactly a bare na. Provably neutral where the shape is absent: transpiling the entire corpus (254-265 sources) with and without the fix produces byte- identical output. The exemplar converges to an exact trade-for-trade TV match; the load-bearing int-na-reset sentinels are byte-identical. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
x := nalowered asx = na<double>();regardless of LHS type. NaN assigned into int/int64/bool storage is UB — ARM64 FCVTZS(NaN)=0 silently destroys the na sentinel (is_nafalse forever), while x86-64's CVTTSD2SI(NaN) coincidentally equals INT64_MIN (the sentinel), masking the bug there. Exemplar: a daily session-open timer (int64,:= naeach new day) never re-armed on ARM64, permanently disabling an open-suppression gate → phantom session-open entries.Fix: the ctor-initializer path already re-typed bare na; the two
:=lowering sites and the function-var-init block now do too, via a resolver that returns the declared scalar type (int / int64_t with epoch promotion / bool / string; None leaves double, collections, UDTs, drawing types untouched), gated on the RHS being exactly a barena.Gates (author + independent fresh-context R7, both green)
🤖 Generated with Claude Code