Closed Bug 359062 Opened 14 years ago Closed 14 years ago
Accessing a generator's local variables from nested functions is broken
A function that is nested in a generator can't get the value of the generator's local variables. Vars in the global scope with the same name are not found either but trying to access these vars doesn't produce a Reference Error. See the attached testcase which should print "Generator string" but prints "undefined undefined". I've tested this with the latest CVS shell and Firefox 2.
Sorry, should have seen this a mile away. /be
OS: Windows Server 2003 → All
Priority: -- → P1
Hardware: PC → All
Target Milestone: --- → mozilla1.9alpha
Comment on attachment 244334 [details] [diff] [review] fix >+/* >+ * Called from the JSOP_GENERATOR case in the interpreter, with fp referring >+ * to the frame by which the generator function was activated. Create a new >+ * JSGenerator object, which contains its own JSStackFrame that we populate >+ * from *fp. We know that upon return, the JSOP_GENERATOR opcode will return >+ * from the activation in fp, so we can steal away fp->callobj and fp->argsobj >+ * if they are non-null. >+ */ r=+ with an extra assert in JSOP_GENERATOR case of the interpreter that fp->callobj and fp->argsobj are NULL after succesful JS_NewGenerator.
With assertion in JSOP_GENERATOR case. /be
Fixed on trunk: Checking in jsinterp.c; /cvsroot/mozilla/js/src/jsinterp.c,v <-- jsinterp.c new revision: 3.303; previous revision: 3.302 done Checking in jsiter.c; /cvsroot/mozilla/js/src/jsiter.c,v <-- jsiter.c new revision: 3.55; previous revision: 3.54 done Thanks for finding this, Seno! /be
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
No problem. Thank you for fixing it so quickly.
Status: RESOLVED → VERIFIED
Checking in regress-359062.js; /cvsroot/mozilla/js/tests/js1_7/geniter/regress-359062.js,v <-- regress-359062.js initial revision: 1.1 done
Comment on attachment 244369 [details] [diff] [review] fix, v2 Approved for 1.8.1 branch, a=jay for drivers. Please land asap. Thanks!
Attachment #244369 - Flags: approval188.8.131.52? → approval184.108.40.206+
Fixed on the 1.8 branch: Checking in jsinterp.c; /cvsroot/mozilla/js/src/jsinterp.c,v <-- jsinterp.c new revision: 220.127.116.11; previous revision: 18.104.22.168 done Checking in jsiter.c; /cvsroot/mozilla/js/src/jsiter.c,v <-- jsiter.c new revision: 22.214.171.124; previous revision: 126.96.36.199 done /be
verified fixed 20061122 188.8.131.52 windows/linux/mac*, 1.9 windows/linux
You need to log in before you can comment on or make changes to this bug.