Unable to evaluate object correctly
See original GitHub issueSee this for example:
duk> {}
= undefined
duk> {test: "foo"}
= "foo"
duk> {"test": "foo"}
SyntaxError: unterminated statement (line 1)
at [anon] (input:1) internal
at [anon] (duk_js_compiler.c:6738) internal
However Node (10 FYI) correctly recognize those constructs:
> {}
{}
> {test: "foo"}
{ test: 'foo' }
> {"test": "foo"}
{ test: 'foo' }
DT “incorrectly” saw object declaration as a statement, which is plausible: It can be object literal
https://github.com/antlr/grammars-v4/blob/master/javascript/JavaScriptParser.g4#L309 I think this is useful.
Workaround: wrap the object “expression” in quotes, which forces it to become a true (super) expression, but statements would fail. Or maybe is that the parser precedence for block statement a bit too high?
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
Unable to evaluate the expression Object has been collected
After pointing my webDriver to the iframe and then the object , my code was running successfully. Share. Share a link to this...
Read more >"Unable to evaluate the expression" - what is the reason?
Each expression has comment: "Unable to evaluate the expression". There are no more explanations. The same problem is with other projects.
Read more >Unable to evaluate expression because the code ... - Rick Strahl
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack. The Web Service...
Read more >failing to evaluate microflow expression - Mendix Forum
You need to check both the object and the attribute of the object for null values before performing a function (i.e. $Employee, and...
Read more >Examine suspended program | IntelliJ IDEA Documentation
If an object has numerous fields, you can pin some of them, ... When examining variables, you may need to copy a variable...
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 Free
Top 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

You could probably also use a trial method where you’d first try to parse as
'(' + expr + ')'and if that fails, parse asexpr.When you say
{ test: "foo" }it doesn’t parse as an object literal, but as a code block with a label:This is the correct parsing with Ecmascript syntax for eval’d code. If you want to eval that, parentheses are needed:
({ test: "foo" }).