archives

« Bugzilla Issues Index

#4356 — Iteration statements return undefined instead of empty


All iteration statements and if statement return "undefined" value when their body is not evaluated, which is not consistent with ES5.1, example:

1; while (false) ;

should evaluate to 1 according to ES5.1, but according to current specification of ES6 will evaluate to "undefined".

The is caused by initializing V to "undefined" in ES6 versus "empty" in ES5.1, for example see ES6 final draft (http://wiki.ecmascript.org/lib/exe/fetch.php?id=harmony%3Aspecification_drafts&cache=cache&media=harmony:ecma-262_6th_edition_final_draft_-04-14-15-markup.pdf) - 13.7.3.6, item 1 - Let V=undefined
but in ES5.1 final draft (http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf) - 12.6.1, item 1 - Let V=empty


This is an intentional change from ES5 based on the completion reform proposal: http://wiki.ecmascript.org/doku.php?id=harmony:completion_reform