-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Describe the bug
This is a follow up to #8317.
Defining a const with ident undefined / NaN / Infinity is syntactically and semantically valid in modules and function bodies. It is also syntactically valid in scripts, but because globalThis.undefined, globalThis.NaN, and globalThis.Infinity are not writable or configurable it fails at runtime in a script.
Input code
const undefined = 0;
console.log(undefined);
const NaN = 0;
console.log(NaN);
const Infinity = 0;
console.log(Infinity);Config
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": true
},
"target": "es2022",
"loose": false,
"minify": {
"compress": false,
"mangle": false
},
"transform": {
"react": {
"importSource": "npm:react",
"runtime": "automatic"
}
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}Playground link (or link to the minimal reproduction)
SWC Info output
No response
Expected behavior
const undefined = 0;
console.log(undefined);
const NaN = 0;
console.log(NaN);
const Infinity = 0;
console.log(Infinity);
Actual behavior
const undefined1 = 0;
console.log(undefined);
const NaN1 = 0;
console.log(NaN);
const Infinity1 = 0;
console.log(Infinity);
Version
1.3.98-nightly-20231118.1
Additional context
No response
Reactions are currently unavailable