-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Other (Next.js, Gatsby, vue-cli, ...)
Input code
"use strict";
let { 0 : x } = { get 0 ( ) { return super [ 0 ] = 0 ; } } ;Configuration file name
No response
Configuration
No response
Current and expected behavior
Running the input.js code should throw TypeError:
// input.js
"use strict";
let { 0 : x } = { get 0 ( ) { return super [ 0 ] = 0 ; } } ;❯ node input.js
input.js:2
let { 0 : x } = { get 0 ( ) { return super [ 0 ] = 0 ; } } ;
^
TypeError: Cannot redefine property: 0
at get 0 [as 0] (/Users/p51lee/dev/esmeta-plrg/.test.js:2:50)
at Object.<anonymous> (/Users/p51lee/dev/esmeta-plrg/.test.js:2:11)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47However, transpilation result throws Error:
// output.js
...
throw new Error("failed to set property");
...❯ node output.js
output.js:38
throw new Error("failed to set property");
^
Error: failed to set property
at _set (/Users/p51lee/dev/esmeta-plrg/.test2.js:38:11)
at get 0 [as 0] (/Users/p51lee/dev/esmeta-plrg/.test2.js:72:14)
at Object.<anonymous> (/Users/p51lee/dev/esmeta-plrg/.test2.js:75:8)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47Environment
Reproduction on Babel's own REPL
Possible solution
Possibly it will be solved by changing the function _set that throws Error("failed to set property") to throw TypeError instead.
Additional context
No response
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue