archives

« Bugzilla Issues Index

#4345 — 15.1.7 ScriptEvaluation: Return NormalCompletion(undefined) in step 1


15.1.7 Runtime Semantics: ScriptEvaluation

Step 1 should probably be changed to:
---
If ScriptBody is not present, return NormalCompletion(undefined).
---


empty is what previous editions returned for empty scripts. It isn't clear that there is any reason to change that.


Previous editions also returned an empty completion value for:
---
; // empty statement
function f() { } // function declaration
{ } // block
---

It doesn't really matter if empty scripts return NormalCompletion(empty) or NormalCompletion(undefined), since the completion value is not detectable by user code, but giving it the same completion value like empty modules and empty eval-scripts seems reasonable. (eval-scripts -> PerformEval, step 4; modules -> 15.2.1.20, first algorithm)

If you don't want to make this change now, maybe defer to ES7 ?


defer to ES7


Fixed in ES2016 Draft (698819c).