Closed Bug 350743 Opened 15 years ago Closed 9 years ago

Decompilation can turn a generator function into a normal (yield-less) function

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: jruderman, Unassigned)

References

Details

(Keywords: testcase)

> z = function () { print(3); if(false) yield 4; }
function () { print(3); }

Calling z() returns a generator immediately, without printing 3.  This seems consistent with http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7 :

"The function containing the yield keyword is a generator. When you call it, its formal parameters are bound to actual arguments, but its body isn't actually evaluated. Instead, a generator-iterator is returned."

But the decompilation of z() does not contain "yield" at all, so calling it does print 3.  So z's decompilation is very different from z.
Current js shell results:
js> z = function () { print(3); if(false) yield 4; }
(function () {print(3);})
js> z()
({})
OS: Mac OS X → All
Hardware: PowerPC → All
This will probably be fixed by the syntax change in bug 666399.
Depends on: harmony:generators
It ended up being fixed by saving the source.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.