question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to evaluate object correctly

See original GitHub issue

See 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:closed
  • Created 5 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
svaaralacommented, Jun 18, 2018

You could probably also use a trial method where you’d first try to parse as '(' + expr + ')' and if that fails, parse as expr.

1reaction
svaaralacommented, Jun 18, 2018

When you say { test: "foo" } it doesn’t parse as an object literal, but as a code block with a label:

{
    test: /* LABEL */
        "foo"  /* expression statement */
}

This is the correct parsing with Ecmascript syntax for eval’d code. If you want to eval that, parentheses are needed: ({ test: "foo" }).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found