fix(ecmascript): mark new Symbol as non side-effect free (#17568)

![Screenshot 2026-01-01 at 22.03.21.png](https://app.graphite.com/user-attachments/assets/bf89d00f-28c7-4625-aad4-51a843de47ab.png)

`new Symbol` throws an error
This commit is contained in:
camc314 committed 2026-01-04 09:40:37 +00:00
1 parent 2e8f469255
commit 1044116c75
2 files changed
+2 -2

No files matched your search

@@ -248,7 +248,7 @@ fn is_pure_call(name: &str) -> bool {
fn is_pure_constructor(name: &str) -> bool {
matches!(name, "Set" | "Map" | "WeakSet" | "WeakMap" | "ArrayBuffer" | "Date"
| "Boolean" | "Error" | "EvalError" | "RangeError" | "ReferenceError"
| "SyntaxError" | "TypeError" | "URIError" | "Number" | "Object" | "String" | "Symbol")
| "SyntaxError" | "TypeError" | "URIError" | "Number" | "Object" | "String")
}
/// Whether the name matches any known global constructors.
@@ -785,6 +785,7 @@ fn test_property_access() {
fn test_new_expressions() {
test("new AggregateError", true);
test("new DataView", true);
test("new Symbol", true);
test("new Set", false);
test("new Map", false);
test("new WeakSet", false);
@@ -803,7 +804,6 @@ fn test_new_expressions() {
test("new Number", false);
test("new Object", false);
test("new String", false);
test("new Symbol", false);
}
// `PF` in <https://github.com/rollup/rollup/blob/master/src/ast/nodes/shared/knownGlobals.ts>