tc39 / proposal-json-parse-with-source

Proposal for extending JSON.parse to expose input source text.
https://tc39.github.io/proposal-json-parse-with-source
MIT License
213 stars 9 forks source link

ShallowestContainedJSONValue misrepresents negative numbers #44

Closed gibson042 closed 11 months ago

gibson042 commented 11 months ago

In JSON, -1 is parsed as a single number token. But in ECMAScript, it is parsed as a UnaryExpression consisting of - and a NumericLiteral. ShallowestContainedJSONValue should therefore characterize numbers as |UnaryExpression| rather than |NumericLiteral|, so that InternalizeJSONProperty defining a "source" property using the source text matched by parseNode correctly sets the value to a string containing any negation prefix.