archives

« Bugzilla Issues Index

#2877 — 7.1.3.1 has weird behavior w.r.t preceding +/- leading to ambiguity


7.1.3.1 says
"A StringNumericLiteral that is decimal may be preceded by + or - to indicate its sign."

But the grammar also explicit includes +/- productions, so this would _imply_ that you could have up to two sign operators.

It also leads to weirdness handling "Infinity" as we explicitly state "-Infinity" is allowed, but don't mention "+Infinity" so I believe it would be reasonable to interpret this as meaning that "+Infinity", "-+Infinity", and "--Infinity" are allowed, _or_ because "Infinity" is not handled by the grammar, we could also interpret the text as not allowing those literals, and logically therefore disallowing "+Infinity".


[Changing this bug's 'Version' from Rev17 to Rev24.
Section 7.1.3.1 didn't exist in Rev17.]


(In reply to comment #0)
> 7.1.3.1 says
> "A StringNumericLiteral that is decimal may be preceded by + or - to indicate
> its sign."

But that's in a Note, so it's non-normative.

It would be clearer if the wording were changed from "may be preceded by" to something like "may start with". (So I think this is an editorial issue, not a technical one.)


This is old language (and as Michael points out, non-normative) that goes back to at least ES3 (it's in 9.3.1 in ES3 and ES5)

I agree that the language could be made less confusing.

fixed in rev25 editor's draft


in rev25