Closed Bug 71107 Opened 25 years ago Closed 25 years ago

lexical closure scoping regression in js breaks ldap datasource

Categories

(Core :: JavaScript Engine, defect, P1)

x86
Linux
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: dmosedale, Assigned: shaver)

Details

(Keywords: js1.5)

Attachments

(1 file)

From IRC: <peterv> dmose: seems the inner objects don't see the variables in the CreateDelegate function anymore <peterv> dmose: JavaScript Error: "connection is not defined" {file: "nsLDAPDataSource.js" line: 831} Looking at the code, it seems possible that the scope chain of the callback function is wrong (ie not lexically closed).
Yeah, we lose. We don't propagate heavyweightness back up the function-nesting chain when we set it in js_EmitTree/TOK_FUNCTION. Simple test case: function outer () { var outer_var = 5; function inner() { function way_inner() { return outer_var; } return way_inner; } return inner; } js> outer()()() /tmp/nest.js:5: ReferenceError: outer_var is not defined Expected: js> outer()()() 5 Patch coming right up.
Severity: normal → critical
Status: NEW → ASSIGNED
Keywords: js1.5
Priority: -- → P1
I crave brendan's r and someone's sr. Phil, can you add this baby to our test suite?
Yes, I will add this test now. Thanks, Mike -
Need fast r= for JS1.5 RC3. /be
Mike's test added to JS test suite: js/tests/js1_5/Regress/regress-71107.js
Just ran the entire JS test suite on WinNT and Linux with Mike's patch applied. Suite now includes the regression test for this bug, above. I got 0 errors -
r=jband
All better. Sorry about that, dmose.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Also ran the new regression test on the Mac - passed. Marking VERIFIED -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: