Member expression on number literal generates wrong output
See original GitHub issuerequire("escodegen").generate({
"type": "ExpressionStatement",
"expression": {
"type": "MemberExpression",
"computed": false,
"object": {
"type": "Literal",
"value": 4,
"raw": "4"
},
"property": {
"type": "Identifier",
"name": "foo"
}
}
})
// => '4..foo;'
While it should output:
(4).foo;
Issue Analytics
- State:
- Created 10 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
Calling member function of number literal - javascript
I get the expected result "23.00" but when I try 23.toFixed(2) I get this error. SyntaxError: Invalid or unexpected token. Why do I ......
Read more >Restrict template literal interpolation expressions to strings
When using string literals, any variables are coerced to strings, which can lead to undesirable behavior. As far as I can tell there's...
Read more >User-defined literals (since C++11) - cppreference.com
Allows integer, floating-point, character, and string literals to produce objects of user-defined type by defining a user-defined suffix.
Read more >Constant and Literal Data Types - Visual Basic - Microsoft Learn
A literal is a value that is expressed as itself rather than as a variable's ... The error results from the representation of...
Read more >Scheme - Expressions
As noted in section Storage model, it is an error to alter a constant (i.e. the value of a literal expression) using a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ah, I think I see what you mean. Thanks, @dannycochran. The fix here would be to compile to
@dannycochran I disagree. Those should be identical in an AST. The fact that they’re not due to
raw
on Literal is the problem.