Repository navigation
Conversation
The verifier normalises number literals by parsing them, and hit unreachable!() for Lua 5.2 hexadecimal floats (0x1p4, 0xA.8p0) and for hexadecimal integers above i64::MAX.
This branch has not been deployed
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.
--verifynormalises number literals before comparing the two ASTs: it triesf64, then hexadecimal asi64, then (Luau) binary, and hitsunreachable!()otherwise. Two kinds of valid literals end up there:0x1p4,0xA.8p0,0x.1p1,0x1.8;0x7fffffffffffffff, such as0xffffffffffffffff.I ran into it on lua-language-server's
test/parser_test/ast/Number.lua.Hexadecimal integers are now parsed as
u64, and anything that still doesn't parse goes through a smallnormalise_hex_float, which computes the value from the mantissa and the binary exponent. If even that fails, the literal is kept as written rather than panicking.Tests:
test_equivalent_hex_numbers_beyond_i64,test_equivalent_hex_float_numbersandtest_different_hex_float_numbersall panic without the change.cargo testpasses with the default features,--no-default-features,--all-featuresand each oflua52,lua53,lua54,luau,luajit,cfxlua;cargo clippy --all-features -- -D warningsandcargo fmt --checkare clean. I also ran a release build with--verifyover about 6,000 Lua/Luau files (Neovim plugins, KOReader, awesome, Kong, APISIX, lua-language-server, Roact, Fusion, ...): there are no more panics.