Repository navigation
Conversation
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.
A quoted property key that looks like a decimal number was turned into a numeric key, but a numeric key is converted back with
ToString(ToNumber(key)), so the key changed:After minify:
The same happens for
".5"(becomes key"0.5"),"5."("5"),"1.50"("1.5") and long integers like"9007199254740993"(rounds to"9007199254740992").parsePropertyNameusedAsDecimalLiteral, which only checks the syntax. The newAsNumericPropertyKeyalso checks that the number prints back to the exact same string (shortest round-trip digits, below 1e21 whereToStringswitches to exponent form).AsDecimalLiteralitself is unchanged.Tests: 5 new cases in
TestParse(4 fail before the change) and a newTestAsNumericPropertyKey. I also checked the new function against node'sString(Number(s)) === sfor 272k random decimal strings: 0 differences.go test ./...passes, and minify'sgo test ./...passes against this branch.minify's
o["1.0"]→o[1](member access,js/js.go) has the same root cause; I'll send that fix to minify once this is in, so it can use the new function.