TDZ buglet in test_eventemitter_basic.html

RESOLVED FIXED in Firefox 35

Status

RESOLVED FIXED
4 years ago
6 months ago

People

(Reporter: tromey, Assigned: tromey)

Tracking

unspecified
Firefox 35
x86_64
Linux
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

4 years ago
I had a "try" build fail in test_eventemitter_basic.html.
The error says in part:

ReferenceError: can't access let declaration `beenHere1' before initialization: next@chrome://mochitests/content/chrome/toolkit/devtools/tests/mochitest/test_eventemitter_basic.html:61:14
ReferenceError: can't access let declaration `beenHere1' before initialization: next@chrome://mochitests/content/chrome/toolkit/devtools/tests/mochitest/test_eventemitter_basic.html:61:14


Looking at `beenHere1' I see:

      function testEmitter(aObject) {
...
        emitter.on("next", next);
        emitter.emit("next", "abc", "def");

        let beenHere1 = false;
        function next(eventName, str1, str2) {
...

So I think that `beenHere1' is calling into the "temporal dead zone":
depending on the circumstances, `next' may be called before `beenHere1'
has been bound.

The fix is to hoist the `let' up above the call to `emitter.on'.
I'll attach a patch momentarily.
(Assignee)

Comment 1

4 years ago
Created attachment 8495260 [details] [diff] [review]
hoist "let"s to avoid the TDZ

I hoisted "beenHere2" as well since it seemed possible for "onlyOnce"
to be called before that let binding was seen.

I looked at the other files in this directory and everything else was
fine.
(Assignee)

Updated

4 years ago
Assignee: nobody → ttromey
(Assignee)

Updated

4 years ago
Attachment #8495260 - Flags: review?(past)
Comment on attachment 8495260 [details] [diff] [review]
hoist "let"s to avoid the TDZ

Review of attachment 8495260 [details] [diff] [review]:
-----------------------------------------------------------------

Nice, I've seen that error recently myself.
Attachment #8495260 - Flags: review?(past) → review+
(Assignee)

Updated

4 years ago
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/d056ffd17f0c
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 35

Updated

4 years ago
Duplicate of this bug: 1074425

Updated

6 months ago
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.