-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kind
field for Literal
#61
Comments
I'm impartial to this since I wouldn't be able to rely on |
I filed a bug out of uncertainty (this would be a modification of the original spec). |
Add |
"infinity" seems like an abuse of this proposal. That "kind" has value on its own, but is insufficient to cover portability, which I think requires either Literal subtypes or "raw". |
@gibson042 The regexp issue has already been solved by #27. |
I would also support a "raw" node as well.
|
Is the same not true of |
Nope, you can represent > 1e10000
Infinity |
Is that true in SpiderMonkey? esprima at least presents Regardless, I maintain that |
@gibson042 In acorn it does at least, sounds like an esprima bug. |
@gibson042: No, it doesn't. You're probably observing the JSON serialisation problem we're talking about. And If you don't think |
D'oh, right you are. 😳
I do think |
I concur with
|
Backward compatibility with what? Who currently implements kind? |
Identifier("Infinity") versus Literal(kind: "infinity"). Tools already
|
@IMPinball We aren't proposing to parse the |
Oh. Thanks for clarifying, although I don't get exactly why such a
|
You can't serialise an infinite numeric literal to JSON. |
What about Also, I'm not sure JSON serialization should be something that drives design of AST itself since, when it's really needed, you can implement callback for |
Adds to the list of reasons why I'm not sure
|
Yeah and checking the type of |
@RReverser there are no negative number literals in JavaScript. |
@michaelficarra Depends on whether AST node was parsed or generated and inserted. In |
@RReverser Technically, a transformer or builder can still emit invalid ASTs. Nothing stops you from doing this, even though it's completely nonsensical. ConditionalExpression(
IfStatement( // invalid
Identifier("Foo"),
null,
BlockStatement([])
),
BlockStatement([ // invalid
NewExpression(
Identifier("Foo"),
[]
)
]),
Literal(0)
) // Your invalid JS-ish result:
(if (Foo) {}) ? { new Foo(); } : 0 As for a negative numeric Literal, that would be an easy PR to make, although it would be breaking. Getting all the tools patched for that should be relatively easy, though. The Literal type does not specifiy that restriction, by the way. |
I do feel we are digressing from the topic, though. As for the current values (without |
That's exactly what I was pointing to by "having negative num was never specified as an invalid state". |
Closed via #63. |
It is very useful for basic type checking, and IMO is a bit less hackish (and easier) than
typeof node.value
. Here's my idea:The text was updated successfully, but these errors were encountered: