Skip to content
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

Wrong hint message when parsing expression such as {a:1}['a'] === 1 in node #31820

Closed
Killea opened this issue Feb 16, 2020 · 6 comments
Closed
Assignees
Labels
repl Issues and PRs related to the REPL subsystem.

Comments

@Killea
Copy link

Killea commented Feb 16, 2020

image

Welcome to Node.js v13.8.0.
Type ".help" for more information.

{a:1}['a'] === 1
false
{a:1}['a'] === 1
true (have not press enter, if press enter it turns to false)

  • Version: 13.8
  • Platform: Linux
  • Subsystem: NA

I tested on Chrome, it always shows false. I'm sure this is a bug.

What steps will reproduce the bug?

Type {a:1}['a'] === 1 in a node console.

How often does it reproduce? Is there a required condition?

Every time.

What is the expected behavior?

The gray font of 'true' in this image should be 'false'!

@targos
Copy link
Member

targos commented Feb 16, 2020

@BridgeAR

@devsnek
Copy link
Member

devsnek commented Feb 16, 2020

The two ways this is parsed:

  • ({ a: 1 }['a'] === 1); in preview
  • { a:1; }; ['a'] === 1; in repl eval

We should probably eagerly try to wrap all input in parens in the actual evaluator.

@addaleax addaleax added the repl Issues and PRs related to the REPL subsystem. label Feb 16, 2020
@codebytere
Copy link
Member

Mind if i take a stab at this one?

@codebytere codebytere self-assigned this Feb 22, 2020
@tniessen
Copy link
Member

We should probably eagerly try to wrap all input in parens in the actual evaluator.

That might break working code, or am I missing something?

class Foo {} function foo() {} contains two valid declarations, but not if wrapped as an expression in parentheses.

@devsnek
Copy link
Member

devsnek commented Feb 24, 2020

@tniessen if the code isn't valid with parens, parens are not used. the logic should more or less be: try { parse(wrap(input)); input = wrap(input); } catch {}

@codebytere
Copy link
Member

Closed in #31943.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

No branches or pull requests

6 participants