镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Description

@Killea

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'!

Activity

  1. targos commented on Feb 16, 2020

    @targos
    Member
  2. devsnek commented on Feb 16, 2020

    @devsnek
    Member

    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.

  3. added
    replIssues and PRs related to the REPL subsystem.
    on Feb 16, 2020
  4. codebytere commented on Feb 18, 2020

    @codebytere
    Member

    Mind if i take a stab at this one?

  5. self-assigned this
    on Feb 22, 2020
  6. tniessen commented on Feb 24, 2020

    @tniessen
    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.

  7. devsnek commented on Feb 24, 2020

    @devsnek
    Member

    @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 {}

  8. codebytere commented on Feb 27, 2020

    @codebytere
    Member

    Closed in #31943.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

replIssues and PRs related to the REPL subsystem.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions