Add tests for "Runtime Errors for Function Call Assignment Targets" (#4459)

* Add tests for ecma262#3568

* "Late" -> "Runtime"

* Check for functions named `async` too.
This commit is contained in:
Ross Kirsling 2025-07-16 01:22:15 +09:00 committed by GitHub
parent f0dc15c6c7
commit 609614febe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
29 changed files with 675 additions and 80 deletions

View File

@ -1,22 +0,0 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-static-semantics-assignmenttargettype
desc: >
Static Semantics AssignmentTargetType, Return invalid.
info: |
CallExpression Arguments
Static Semantics AssignmentTargetType, Return invalid.
template: invalid
negative:
phase: parse
type: SyntaxError
---*/
//- assignmenttarget
f()
//- operator
=
//- value
1

View File

@ -0,0 +1,23 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-static-semantics-assignmenttargettype
desc: >
Static Semantics AssignmentTargetType, Return web-compat.
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
template: invalid/statement
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict]
---*/
//- statement
for (f() in [1]) {}

View File

@ -0,0 +1,23 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-static-semantics-assignmenttargettype
desc: >
Static Semantics AssignmentTargetType, Return web-compat.
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
template: invalid/statement
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict]
---*/
//- statement
for (f() of [1]) {}

View File

@ -0,0 +1,27 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-static-semantics-assignmenttargettype
desc: >
Static Semantics AssignmentTargetType, Return web-compat.
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
template: invalid
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict]
---*/
//- assignmenttarget
f()
//- operator
+=
//- value
1

View File

@ -0,0 +1,26 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-static-semantics-assignmenttargettype
desc: >
Static Semantics AssignmentTargetType, Return web-compat.
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
template: invalid
negative:
phase: parse
type: SyntaxError
---*/
//- assignmenttarget
f()
//- operator
&&=
//- value
1

View File

@ -0,0 +1,23 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-static-semantics-assignmenttargettype
desc: >
Static Semantics AssignmentTargetType, Return web-compat.
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
template: invalid/statement
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict]
---*/
//- statement
f()++;

View File

@ -0,0 +1,23 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-static-semantics-assignmenttargettype
desc: >
Static Semantics AssignmentTargetType, Return web-compat.
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
template: invalid/statement
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict]
---*/
//- statement
++f();

View File

@ -0,0 +1,28 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-static-semantics-static-semantics-assignmenttargettype
desc: >
Static Semantics AssignmentTargetType, Return web-compat.
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
template: invalid
negative:
phase: parse
type: SyntaxError
flags: [onlyStrict]
---*/
//- assignmenttarget
f()
//- operator
=
//- value
1

View File

@ -1,15 +0,0 @@
// Copyright (C) 2020 Rick Waldron. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/assignmenttargettype/iteration-direct-
name: Direct assignment
info: |
Direct assignment
---*/
$DONOTEVALUATE();
function _() {
for (/*{ assignmenttarget }*/ /*{ operator }*/ /*{ value }*/) {}
}

View File

@ -0,0 +1,12 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
path: language/expressions/assignmenttargettype/direct-
name: Direct assignment
info: |
Direct assignment
---*/
$DONOTEVALUATE();
/*{ statement }*/

View File

@ -0,0 +1,31 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-errors-for-function-call-assignment-targets
description: Function call as for-in LHS is a runtime ReferenceError
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
flags: [noStrict]
---*/
var fCalled = false;
var fValueOfCalled = false;
function f() {
fCalled = true;
return {
valueOf() { fValueOfCalled = true; return 1; }
};
}
assert.throws(ReferenceError, function() {
for (f() in [1]) {}
});
assert(fCalled);
assert(!fValueOfCalled);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-errors-for-function-call-assignment-targets
description: Function call as for-of LHS is a runtime ReferenceError
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
flags: [noStrict]
---*/
var fCalled = false;
var fValueOfCalled = false;
function f() {
fCalled = true;
return {
valueOf() { fValueOfCalled = true; return 1; }
};
}
assert.throws(ReferenceError, function() {
for (f() of [1]) {}
});
assert(fCalled);
assert(!fValueOfCalled);

View File

@ -0,0 +1,38 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-errors-for-function-call-assignment-targets
description: Function call LHS in compound assignment is a runtime ReferenceError
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
flags: [noStrict]
---*/
var fCalled = false;
var fValueOfCalled = false;
function f() {
fCalled = true;
return {
valueOf() { fValueOfCalled = true; return 1; }
};
}
var gCalled = false;
function g() {
gCalled = true;
return 1;
}
assert.throws(ReferenceError, function() {
f() += g();
});
assert(fCalled);
assert(!fValueOfCalled);
assert(!gCalled);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-errors-for-function-call-assignment-targets
description: Function call in postfix update expression is a runtime ReferenceError
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
flags: [noStrict]
---*/
var fCalled = false;
var fValueOfCalled = false;
function f() {
fCalled = true;
return {
valueOf() { fValueOfCalled = true; return 1; }
};
}
assert.throws(ReferenceError, function() {
f()++;
});
assert(fCalled);
assert(!fValueOfCalled);

View File

@ -0,0 +1,31 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-errors-for-function-call-assignment-targets
description: Function call in prefix update expression is a runtime ReferenceError
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
flags: [noStrict]
---*/
var fCalled = false;
var fValueOfCalled = false;
function f() {
fCalled = true;
return {
valueOf() { fValueOfCalled = true; return 1; }
};
}
assert.throws(ReferenceError, function() {
++f();
});
assert(fCalled);
assert(!fValueOfCalled);

View File

@ -0,0 +1,38 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-errors-for-function-call-assignment-targets
description: Function call LHS in `=` assignment is a runtime ReferenceError
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
flags: [noStrict]
---*/
var fCalled = false;
var fValueOfCalled = false;
function f() {
fCalled = true;
return {
valueOf() { fValueOfCalled = true; return 1; }
};
}
var gCalled = false;
function g() {
gCalled = true;
return 1;
}
assert.throws(ReferenceError, function() {
f() = g();
});
assert(fCalled);
assert(!fValueOfCalled);
assert(!gCalled);

View File

@ -0,0 +1,41 @@
// Copyright (C) 2025 Sony Interactive Entertainment Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-runtime-errors-for-function-call-assignment-targets
description: Function call assignment target is still a runtime ReferenceError when the function is named `async`
info: |
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
flags: [noStrict]
---*/
function async() {}
assert.throws(ReferenceError, function() {
async() = 1;
});
assert.throws(ReferenceError, function() {
async() += 1;
});
assert.throws(ReferenceError, function() {
async()++;
});
assert.throws(ReferenceError, function() {
++async();
});
assert.throws(ReferenceError, function() {
for (async() in [1]) {}
});
assert.throws(ReferenceError, function() {
for (async() of [1]) {}
});

View File

@ -1,20 +0,0 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-arguments.case
// - src/assignment-target-type/invalid/direct.template
/*---
description: Static Semantics AssignmentTargetType, Return invalid. (Direct assignment)
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Direct assignment
CallExpression Arguments
Static Semantics AssignmentTargetType, Return invalid.
---*/
$DONOTEVALUATE();
f() = 1;

View File

@ -0,0 +1,24 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-as-for-in-lhs.case
// - src/assignment-target-type/invalid/statement/default.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (Direct assignment)
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
Direct assignment
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
for (f() in [1]) {}

View File

@ -0,0 +1,24 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-as-for-of-lhs.case
// - src/assignment-target-type/invalid/statement/default.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (Direct assignment)
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
Direct assignment
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
for (f() of [1]) {}

View File

@ -0,0 +1,24 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-in-compound-assignment.case
// - src/assignment-target-type/invalid/direct.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (Direct assignment)
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
Direct assignment
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
f() += 1;

View File

@ -0,0 +1,24 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-in-logical-assignment.case
// - src/assignment-target-type/invalid/direct.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (Direct assignment)
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
Direct assignment
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
f() &&= 1;

View File

@ -0,0 +1,24 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-in-postfix-update.case
// - src/assignment-target-type/invalid/statement/default.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (Direct assignment)
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
Direct assignment
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
f()++;

View File

@ -0,0 +1,24 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-in-prefix-update.case
// - src/assignment-target-type/invalid/statement/default.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (Direct assignment)
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
Direct assignment
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
++f();

View File

@ -0,0 +1,24 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression.case
// - src/assignment-target-type/invalid/direct.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (Direct assignment)
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
Direct assignment
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
f() = 1;

View File

@ -1,23 +0,0 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-arguments.case
// - src/assignment-target-type/invalid/parenthesized.template
/*---
description: Static Semantics AssignmentTargetType, Return invalid. (ParenthesizedExpression)
esid: sec-grouping-operator-static-semantics-assignmenttargettype
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
ParenthesizedExpression: (Expression)
Return AssignmentTargetType of Expression.
CallExpression Arguments
Static Semantics AssignmentTargetType, Return invalid.
---*/
$DONOTEVALUATE();
(f()) = 1;

View File

@ -0,0 +1,27 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-in-compound-assignment.case
// - src/assignment-target-type/invalid/parenthesized.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (ParenthesizedExpression)
esid: sec-grouping-operator-static-semantics-assignmenttargettype
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
ParenthesizedExpression: (Expression)
Return AssignmentTargetType of Expression.
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
(f()) += 1;

View File

@ -0,0 +1,27 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression-in-logical-assignment.case
// - src/assignment-target-type/invalid/parenthesized.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (ParenthesizedExpression)
esid: sec-grouping-operator-static-semantics-assignmenttargettype
flags: [generated]
negative:
phase: parse
type: SyntaxError
info: |
ParenthesizedExpression: (Expression)
Return AssignmentTargetType of Expression.
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
(f()) &&= 1;

View File

@ -0,0 +1,27 @@
// This file was procedurally generated from the following sources:
// - src/assignment-target-type/callexpression.case
// - src/assignment-target-type/invalid/parenthesized.template
/*---
description: Static Semantics AssignmentTargetType, Return web-compat. (ParenthesizedExpression)
esid: sec-grouping-operator-static-semantics-assignmenttargettype
flags: [generated, onlyStrict]
negative:
phase: parse
type: SyntaxError
info: |
ParenthesizedExpression: (Expression)
Return AssignmentTargetType of Expression.
CallExpression :
CoverCallExpressionAndAsyncArrowHead
CallExpression Arguments
1. If the host is a web browser or otherwise supports Runtime Errors for Function Call Assignment Targets, then
a. If IsStrict(this CallExpression) is false, return ~web-compat~.
2. Return ~invalid~.
---*/
$DONOTEVALUATE();
(f()) = 1;