Skip to content

fix(global): GlobalDeclarationInstantiation must throw TypeError on non-extensible/non-configurable global (6 test262 failures) #464

Description

@dowdiness

Failure summary

6 tests fail (3 files × strict + non-strict), all in test262/test/language/global-code/:

  • script-decl-var-err.js — var declaration on non-extensible global
  • script-decl-func-err-non-extensible.js — function declaration on non-extensible global
  • script-decl-func-err-non-configurable.js — function declaration when property is non-configurable

All fail with: Expected a TypeError to be thrown but no exception was thrown at all

Reproduction

make test262-filter FILTER=language/global-code/script-decl-var-err
make test262-filter FILTER=language/global-code/script-decl-func-err

Spec

ES2024 section 15.1.11 GlobalDeclarationInstantiation:

  • Step 9 (for functions): calls CanDeclareGlobalFunction(fn), throws TypeError if false
  • Step 12 (for vars): calls CanDeclareGlobalVar(vn), throws TypeError if false

Section 9.1.1.4.15 CanDeclareGlobalVar returns false when the global has no matching own property AND IsExtensible(globalObject) is false.

Section 9.1.1.4.16 CanDeclareGlobalFunction returns false when the property does not exist and global is non-extensible, OR when the property is non-configurable and non-writable/non-enumerable.

The engine silently allows the declaration instead of throwing.

Source files

GlobalDeclarationInstantiation likely lives in the interpreter's module/script evaluation path. The CanDeclareGlobalVar/CanDeclareGlobalFunction predicates need to be checked and their false-return paths need to throw TypeError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    conformanceECMAScript conformance

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions