Open
Conversation
…mitting wrong Lua All four constants evaluated to Infinity or -Infinity in Lua. Additionally, MIN_SAFE_INTEGER and MIN_VALUE emitted identical code, as did MAX_SAFE_INTEGER and MAX_VALUE. The existing test did not catch this because it only checked Lua-side results with comparisons that the wrong values accidentally satisfied.
lolleko
approved these changes
Mar 28, 2026
Member
lolleko
left a comment
There was a problem hiding this comment.
Nice good catches i think this has been broken since we added these constants in #1492
Switching to expectToMatchJsResult in tests gives me confidence that everything is correct.
In theory this breaks API / behvaiour, in this case that is warranted though.
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.
For reference, the correct ordering is:
NEGATIVE_INFINITY < MIN_SAFE_INTEGER < 0 < MIN_VALUE < EPSILON < MAX_SAFE_INTEGER < MAX_VALUE < POSITIVE_INFINITYAll four
Numberconstants emit wrong Lua — they all end up asinfor-inf:MAX_SAFE_INTEGER2 ^ 1024→inf2 ^ 53 - 1MIN_SAFE_INTEGER-2 ^ 1074→-inf-(2 ^ 53 - 1)MIN_VALUE-2 ^ 1074→-inf2 ^ -1074MAX_VALUE2 ^ 1024→inf(2 - 2 ^ -52) * 2 ^ 1023Also
MIN_SAFE_INTEGERandMIN_VALUEwere emitting identical code, same forMAX_SAFE_INTEGERandMAX_VALUE.You can verify with:
See Number on MDN for the correct values.
Repro in the TSTL playground: https://typescripttolua.github.io/play/#code/5.4/MYewdgziA2CmB00QHMAUAiAsgQQBoH0BlbAMQFF8BJAOQBUyBxMgJQC50AaAAmoFcBbAEawATvBwFi5KnUYsAlAG4uXAPSquATgAM2gOwBGTZoBMAVgAsei9uMGAUKEgwESNFhpFSFGvSZtOHgFhMUxPKR9ZfyUVdS4AWh19I1NLa1tNBycoOEQUDDDqfAA1bAAZAFUydm4+IVFxT1LKshiVdo7OtQ0zWHiAZhMLR3Ac13ysPBLyqpqg+tCp5qq2rrXurgN4PU09ADZNfoN+iwAOPZMjsz1YAGp+7VOgA
The existing test didn't catch this because it used
expectToEqual(true)with comparisons that the wrong values accidentally satisfied (e.g.-inf <= -infistrue). Switched toexpectToMatchJsResultwith stricter comparisons that actually verify the ordering and specific values.