ladybird/Tests/LibJS/Runtime
Andreas Kling 5cefa59116 LibJS: Fix evaluation order of computed property keys in object literals
The spec for PropertyDefinitionEvaluation requires that when evaluating
a property definition with a computed key (PropertyDefinition :
PropertyName : AssignmentExpression), the PropertyName is fully
evaluated (including ToPropertyKey, which calls ToPrimitive) before the
value's AssignmentExpression is evaluated.

Our bytecode compiler was evaluating the key expression first, then
the value expression, and only performing ToPropertyKey later inside
PutByValue at runtime. This meant user-observable side effects from
ToPrimitive (such as calling Symbol.toPrimitive or toString on the key
object) would fire after the value expression had already been
evaluated.

Fix this by using a new ToPrimitiveWithStringHint instruction that
performs ToPrimitive with string hint(!), and emitting it between the
key and value evaluations in ObjectExpression codegen.
After ToPrimitive, the key is already a primitive, so the subsequent
ToPropertyKey inside PutByValue becomes a no-op from the perspective
of user-observable side
effects.

Also update an existing test that was asserting the old (incorrect)
evaluation order, and add comprehensive new tests for computed property
key evaluation order.
2026-02-09 01:23:48 +01:00
..
builtins LibRegex: Reject RSeekTo crossing the current-to-EOL boundary 2026-02-07 14:09:56 +01:00
classes LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
functions LibJS: Mark named function expression identifiers at individual level 2026-01-27 10:58:39 +01:00
iterators LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
loops LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
math LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
modules LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
operators LibJS: Produce negative zero from i32 multiplication fast path 2026-02-08 20:59:20 +01:00
regress LibJS: Consume identifier when matching an identifier name in bindings 2026-02-06 16:09:33 +01:00
syntax LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
add-values-to-primitive.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
arguments-callee.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
arguments-object.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
assignment-evaluation-order.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
async-this-value.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
automatic-semicolon-insertion.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
break-continue-syntax-errors.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
comments-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
computed-property-key-evaluation-order.js LibJS: Fix evaluation order of computed property keys in object literals 2026-02-09 01:23:48 +01:00
computed-property-sideeffects.js LibJS: Fix evaluation order of computed property keys in object literals 2026-02-09 01:23:48 +01:00
computed-property-throws.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
const-declaration-missing-initializer.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
const-reassignment.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
copy-this-to-local.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
custom-@@hasInstance.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
custom-@@toPrimitive.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
custom-@@toStringTag.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
debugger-statement.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
dictionary-delete-caching.js LibJS: Keep dictionary-mode shapes cacheable after property deletion 2026-01-27 10:58:39 +01:00
dictionary-shape-stress.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
duplicated-variable-declarations.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
empty-statements.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
eval-aliasing.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
eval-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
eval-global-identifier-optimization.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
eval-redeclaration.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
exception-in-catch-block.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
exception-ReferenceError.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
exponentiation-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
for-loop-per-iteration-env-bug.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
gc-deeply-nested-object-graph.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
global-object-getter-setter-this-value.js LibJS: Pass the global object as receiver in GetGlobal 2026-02-08 20:59:20 +01:00
global-var-let-const.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
ic-non-extensible-object.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
if-statement-function-declaration.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
indexed-access-prototype-indirection.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
indexed-access-stress.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
indexed-access-string-object.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
inline-cache-edge-cases.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
inline-cache-stress.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
invalid-lhs-in-assignment.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
labels.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
let-scoping.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
new-expression.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
non-writable-assignment.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
null-or-undefined-access.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
numeric-literals-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-expression-__proto__.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-expression-computed-property.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-expression-numeric-property.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-getter-setter-shorthand.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-literal-caching.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-literal-numeric-keys.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-method-shorthand.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
object-rest-destructuring-assignment.js LibJS: Fix object rest destructuring with MemberExpression target 2026-02-09 01:23:48 +01:00
object-spread.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
ordinary-to-primitive.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
parseInt.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
parser-declaration-in-single-statement-context.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
parser-invalid-destructuring-assignment-target.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
parser-line-terminators.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
parser-unary-associativity.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
permanently-screwed-by-eval.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
postfix-increment-eval-order.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
redefine-next-in-builtin-iterators.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
redefine-prototype-of-builtin-iterators.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
return.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
runtime-error-call-stack-size.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
scope-local-eval-deopt.js LibJS: Detect direct eval calls in parse_call_expression() 2026-02-07 18:05:41 +01:00
statement-with-many-labels.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
strict-mode-errors.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
string-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
string-concatenation.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
string-escapes.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
string-spread.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
super-computed-property-key.js LibJS: Remove outdated FIXME comments about ToPropertyKey ordering 2026-02-09 01:23:48 +01:00
switch-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
switch-break.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
switch-default-before-case.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
tagged-template-literal-with-this.js LibJS: Preserve this binding for tagged with identifiers 2026-02-09 01:23:48 +01:00
tagged-template-literals.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
template-literals.js LibJS: Reduce number of template literal op codes 2026-01-31 18:24:02 +01:00
test-common-tests.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
test-common.js LibWasm: Take call arguments and results on registers if possible 2026-02-02 14:11:49 +01:00
this-value-strict.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
this-value.js LibJS: Remove stale FIXME about sloppy-mode this in CallExpression 2026-02-08 20:59:20 +01:00
throw-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
to-number-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
to-number-exception.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
try-catch-finally-nested.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
try-catch-finally-return.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
try-catch-finally.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
try-finally-break.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
try-finally-continue.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
try-return-finally.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
unicode-identifier-escape.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
update-expression-on-member-expression.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
update-expressions-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
using-declaration.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
using-for-loops.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
var-multiple-declarator.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
var-scoping.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
variable-undefined.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00
with-basic.js LibJS: Move tests to /Tests/LibJS 2026-01-22 07:46:48 -05:00