Repository navigation
-0 kept by unary minus and the literal -0; a getter read as a statement runs; bigint + - * with an int in 64 bits - #941
Merged
Conversation
…nt runs; bigint + - * with an int in 64 bits - Unary minus of a float lowered to 0.0 - x, which is +0 for 0: now arith.negf. A literal -0 folded to the integer 0: now the number -0. 1 / -v and 1 / -0 were Infinity. - `obj.prop;` on its own: the canonicalizer erased the unused getter, and with it whatever the getter does. An accessor op that is an expression statement is now kept. (A field read through an interface whose class has a getter is a plain load, still dropped when unused.) - bigint was not on the numeric promotion ladder, so `n * 1000000000`, `n + 1` and `1 + n` met at the literal's s32 and were cut to 32 bits. It is now the 64-bit rung above i64/s64. Found while adding Temporal, DataView and Float16Array to the default library. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A field of an interface may be a cell of accessors, read by a plain ts.Load that calls the getter when it is lowered; an unused load was dead and the getter never ran. LoadOp now gives its memory effects itself: a read, and for a load that is a statement of its own (__getter_statement) a write as well, so it is kept. Other loads are as they were. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A cast from a signed or signless integer to bigint fell through to the zero-extension: `const b: bigint = -5` held 4294967291. The old promotion hid it by cutting the bigint back to 32 bits; with bigint on the ladder the int is widened to it, so `b < 0` was false and the default library's temporal_duration_instant and disposable_stack failed under wasm. Co-Authored-By: Claude Opus 5.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.
Three wrong results found while adding Temporal, DataView and Float16Array to the default library (ASDAlexander77/TypeScriptCompilerDefaultLib#108, which works around all three):
-xof a float 0 was +0.NegativeOpValuelowered float negation to0.0 - x; it is nowarith.negf. A literal-0folded to the integer0; it is now the number-0. Before the fix,1 / -vand1 / -0wereInfinity. Anintoperand stays an int.obj.prop;never called the getter.RemoveUnusedAccessorerased any getter whose result was unused, along with whatever the getter does (count its calls, throw). An accessor op that is an expression statement now carries__getter_statement, and the canonicalizer keeps it.iface.field;) is a plaints.Load, which calls the class's getter when the field's slot is an accessor cell.LoadOpnow declares its own memory effects: a read, plus a write when the load carries__getter_statement, so dead-code removal andRemoveUnusedkeep that load. Every other load is unchanged.bigint * 1000000000,n + 1and1 + nwere done in 32 bits.bigintwas missing fromnumericPromotionOrder(), so both operands were cast to the literal'ssi32. It is now the 64-bit rung abovei64/s64, andisPromotableNumericaccepts it.Tests
00negative_zero.ts,00getter_statement.ts,00bigint_mixed_arith.ts. Each runs under gc and own, compiled and under the JIT, and under rc and none throughTSLANG_CORPUS.ctest -C Releaseon Windows x64: 8465/8465 passed (3 disabled).🤖 Generated with Claude Code