Version
v26.3.0
Platform
Darwin 24.6.0 Darwin Kernel Version 24.6.0: xnu-11417.140.69.705.2~1/RELEASE_ARM64_T6041 arm64 (macOS, Apple Silicon)
Subsystem
vm
What steps will reproduce the bug?
A let declaration that collides with a non-configurable property on a vm context's global object is no longer rejected with a SyntaxError. Save as repro.js and run with node repro.js:
const vm = require('vm');
const context = vm.createContext({});
// Define a non-configurable ("restricted") property on the context global.
vm.runInContext(
"Object.defineProperty(this, 'foo', { value: 1, configurable: false });",
context
);
// Per ECMA-262 GlobalDeclarationInstantiation step 3.d, a lexical
// declaration colliding with a restricted global property must throw.
try {
vm.runInContext('let foo;', context);
console.log('NO ERROR (let foo; was accepted)');
} catch (e) {
console.log('THREW:', e.constructor.name, '-', e.message);
}
How often does it reproduce? Is there a required condition?
100% reproducible.
What is the expected behavior? Why is that the expected behavior?
let foo; should throw a SyntaxError, because foo is a non-configurable own property of the global object. v24.12.0 behaves correctly: THREW: SyntaxError - Identifier 'foo' has already been declared
What do you see instead?
On v26.3.0 the declaration is silently accepted: NO ERROR (let foo; was accepted)
Additional information
Found via the test262 language/global-code/script-decl-lex-restricted-global.js case.
Version
v26.3.0
Platform
Subsystem
vm
What steps will reproduce the bug?
A let declaration that collides with a non-configurable property on a vm context's global object is no longer rejected with a SyntaxError. Save as repro.js and run with node repro.js:
How often does it reproduce? Is there a required condition?
100% reproducible.
What is the expected behavior? Why is that the expected behavior?
let foo;should throw aSyntaxError, because foo is anon-configurableown property of the global object. v24.12.0 behaves correctly: THREW:SyntaxError - Identifier 'foo' has already been declaredWhat do you see instead?
On v26.3.0 the declaration is silently accepted:
NO ERROR (let foo; was accepted)Additional information
Found via the test262
language/global-code/script-decl-lex-restricted-global.jscase.