Skip to content

Wrong behaviour of console.log in node 10 #34610

@oscaretu

Description

@oscaretu
  • Version: 10.20.1
  • Platform: Windows 10 Home, 64 bit
  • Subsystem: Windows on Linux (WSL)

What steps will reproduce the bug?

If you execute this program with v10.20.1:

'use strict';

let dead = Buffer.alloc(1023, 'DEADBEEF', 'hex');

console.log("\n* The next one shows an 'n' suffix:\n");

console.log(dead.readBigUInt64BE(6) );

console.log("\n* The next one doesn't show an 'n' suffix:\n");
console.log('dead.readBigUInt64BE(6) [dec]: ', dead.readBigUInt64BE(6) );

console.log("\n => The only difference is that before the number a text was shown. Is right this behaviour?\n");

console.log("* But it shows the 'n' suffix in I invert the order of the two parameters:\n");
console.log(dead.readBigUInt64BE(6), " <= dead.readBigUInt64BE(6) [dec]\n");

you get

* The next one shows an 'n' suffix:

13758460224454254253n

* The next one doesn't show an 'n' suffix:

dead.readBigUInt64BE(6) [dec]:  13758460224454254253

 => The only difference is that before the number a text was shown. Is right this behaviour?

* But it shows the 'n' suffix in I invert the order of the two parameters:

13758460224454254253n ' <= dead.readBigUInt64BE(6) [dec]\n'

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

It appears always if I use the v10.20.1 version. It doesn't happen if I use versions v12.18.3 or v14.7.0

What is the expected behavior?

You shoudn't get this:

dead.readBigUInt64BE(6) [dec]:  13758460224454254253

but

dead.readBigUInt64BE(6) [dec]:  13758460224454254253n

(with a "n" suffix at the end of the number)

And you shouldn't get this:

' <= dead.readBigUInt64BE(6) [dec]\n'

but this (without single quotes, and with a new line instead of \n):

 <= dead.readBigUInt64BE(6) [dec]

Metadata

Metadata

Assignees

No one assigned

    Labels

    consoleIssues and PRs related to the console subsystem.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions