Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions src/assignment-target-type/callexpression-arguments.case

This file was deleted.

23 changes: 23 additions & 0 deletions src/assignment-target-type/callexpression-as-for-in-lhs.case
Original file line number Diff line number Diff line change
@@ -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]) {}
23 changes: 23 additions & 0 deletions src/assignment-target-type/callexpression-as-for-of-lhs.case
Original file line number Diff line number Diff line change
@@ -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]) {}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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()++;
23 changes: 23 additions & 0 deletions src/assignment-target-type/callexpression-in-prefix-update.case
Original file line number Diff line number Diff line change
@@ -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();
28 changes: 28 additions & 0 deletions src/assignment-target-type/callexpression.case
Original file line number Diff line number Diff line change
@@ -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
15 changes: 0 additions & 15 deletions src/assignment-target-type/invalid/iteration/direct.template

This file was deleted.

12 changes: 12 additions & 0 deletions src/assignment-target-type/invalid/statement/default.template
Original file line number Diff line number Diff line change
@@ -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 }*/
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -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);
Loading
Loading