archives

« Bugzilla Issues Index

#4428 — Annex B.3.3, needs to apply to Scripts as well as FunctionDeclarations


In addition to modify the FunctionDeclarationInstantiation abstract operation, Annex B.3.3 also needs to modify the GlobalDeclarationInstantiation operations.

The steps similar to the replace steps given for FDI step 29 need to be inserted immediately after step 12 of GlobalDeclarationInstantiation (15.1.8). The only differences in the replacement steps are:

1.a: apply the changes described in Bug 4427
1.a.ii.2 and 1.a.ii.2: Replace /instantiatedVarNames/ with /declaredVarNames/
1.a.ii.2.a and 1.a.ii.2.c: Replace /varEnvRec/ with /envRec/


Also see https://esdiscuss.org/topic/block-level-function-declarations-web-legacy-compatibility-bug


Adding block-scoped function declarations to scripts requires more (static and dynamic) checks, that's why I thought B.3.3 was restricted to functions.

Additional checks:
- Check HasLexicalDeclaration() is false
- Check CanDeclareGlobalFunction() is true
- Install the global binding with CreateGlobalFunctionBinding()

I've put up a gist to show the additional changes:
https://gist.github.com/anba/07c83c4137990bdaa932

(It's not quite clear to me if the binding should be installed using CanDeclareGlobalFunction+CreateGlobalFunctionBinding or alternatively using CanDeclareGlobalVar+CreateGlobalVarBinding.)