Closed Bug 1605835 Opened 6 years ago Closed 6 years ago

`({ 1n: 1 })` should not throw syntax error

Categories

(Core :: JavaScript Engine, defect, P1)

71 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: public, Assigned: anba)

References

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36

Steps to reproduce:

Run a JavaScript code ({ 1n: 1 })

Actual results:

SyntaxError: expected property name, got bigint literal

Expected results:

It makes an object { 1: 1 }.


PropertyName contains BigInt literals. And I couldn't find any early errors for BigInt literals.

As the Evaluation section, if a property name is a numeric literal, the property name should be ToString of the numeric value.

Hi, Toru Nagashima!

Thanks for your contribution!

I don't have deep knowledge in JavaScript but I've checked according to the steps described with one of the devs here and we are receiving the same message on firefox and chrome. If this is not the intended or expected behavior, please respond to the thread here so we keep investigating.

Please let us know if this issue is reproduced in the latest Nightly edition. You can download it from here: https://nightly.mozilla.org/

Once you have all this information, please let us know so we can continue investigating.

Regards,

Flags: needinfo?(public)
Attached image chromejs.png
Attached image ffjs.png

Clearing NI because this is a valid bug, it just happens to be a bug present in both Firefox and Chrome.

Status: UNCONFIRMED → NEW
Component: Untriaged → JavaScript Engine
Ever confirmed: true
Flags: needinfo?(public)
Product: Firefox → Core
Assignee: nobody → andrebargull
Status: NEW → ASSIGNED

BytecodeEmitter.cpp:

  • ParseNode::getConstantValue directly calls BigIntLiteral::value() to match the
    existing use in that function. This is incompatible with deferred gc-things
    allocation, but doesn't matter in practice, because this all happens in dead code
    anyway.
  • Drive-by change in emitObjLiteralValue(): Call MOZ_CRASH instead of returning
    false for unhandled parse nodes. And also assert the function is only called
    with valid parse nodes in the first place.

NameFunctions.cpp:

  • BigInts aren't currently supported for guessed names, so just I've only updated
    the assertion condition.

Parser.cpp:

  • Update spec reference from NumericLiteralBase to NonDecimalIntegerLiteral.
  • The new bigIntAtom() function runs counter to the deferred gc-things work,
    but this inevitable as long as function names are computed in the parser.
Priority: -- → P1
Pushed by nerli@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/66693433b026 Allow BigInts as property names. r=mgaudet

It looks like the displayName testing function can't unwrap wrappers.

Flags: needinfo?(andrebargull)
Pushed by cbrindusan@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/48303a40dd45 Allow BigInts as property names. r=mgaudet
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla74
QA Whiteboard: [qa-74b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: