Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Array<RegExp>.toString() doesn't work properly on Node.js CLI #44417

Copy link
Copy link
@yukha-dw

Description

@yukha-dw
Issue body actions

Version

v16.13.1

Platform

Microsoft Windows NT 10.0.19044.0 x64

Subsystem

No response

What steps will reproduce the bug?

Hello, I've found interesting bug on Node.js CLI on Windows Console and also on WSL.

These code will work as intended when being run inside a file (node index.js) or copy to CLI simultaneously, but won't work if we run it line by line.

const arr = [/asd/,/cvb/];

first=`${arr.toString()}`;
console.log({first});

arr.toString();

second=`${arr.toString()}`;
console.log({second});

After running arr.toString(); without assigning to a variable, the arr variable will broke and failed to return correct string.

Output

Scenario: node index.js

{ first: '/asd/,/cvb/' }
{ second: '/asd/,/cvb/' }

Scenario: Copy to Node.js CLI simultaneously

Welcome to Node.js v16.13.1.
Type ".help" for more information.
> const arr = [/asd/,/cvb/];
undefined
>
> first=`${arr.toString()}`;
'/asd/,/cvb/'
> console.log({first});
{ first: '/asd/,/cvb/' }
undefined
>
> arr.toString();
'/asd/,/cvb/'
>
> second=`${arr.toString()}`;
'/asd/,/cvb/'
> console.log({second});
{ second: '/asd/,/cvb/' }
undefined
>

Bugged Scenario: Run Line by Line on Node.js CLI

Welcome to Node.js v16.13.1.
Type ".help" for more information.
> const arr = [/asd/,/cvb/];
undefined
> first=`${arr.toString()}`;
'/asd/,/cvb/'
> console.log({first});
{ first: '/asd/,/cvb/' }
undefined
>
> arr.toString();
''
>
> second=`${arr.toString()}`;
''
> console.log({second});
{ second: '' }
undefined
>

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

On right condition, it happens all the time.

What is the expected behavior?

arr variable does not change internally and able to return correct string using .toString() method.

What do you see instead?

arr.toString() returns blank string and becomes broken.

Additional information

No response

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.