Unexpected ReferenceError

34 views
Skip to first unread message

Joa Ebert

unread,
May 25, 2015, 11:51:06 AM5/25/15
to streng...@googlegroups.com
Hey,

I am currently implementing strong mode in defrac. Everything went smooth so far but I am experiencing an error I can't explain.
The following works as expected:

(function() {
"use strong";
class A {
  static neu() {
    new B()
  }
  constructor() {
    new B()
  }
}

class B {
  constructor() { print("B"); }
}
A.neu(); //B
new A(); //B
})();

But for some reason I get a ReferenceError when running a more complex example.
d8 --strong-mode --harmony_arrow_functions app.js
app.js:105: ReferenceError: In strong mode, declaring variable 'java_lang_Throwable' before its use is required
if(e0 instanceof java_lang_Throwable) {
                 ^^^^^^^^^^^^^^^^^^^
ReferenceError: In strong mode, declaring variable 'java_lang_Throwable' before its use is required

The source file causing the issue is attached. Compiling it with Traceur works so I don't suspect a syntax error causing the issue.
I'm on V8 commit 83321b0


Best,
Joa
app.js

Andreas Rossberg

unread,
Jun 1, 2015, 8:52:11 AM6/1/15
to Joa Ebert, streng...@googlegroups.com
On 25 May 2015 at 17:51, Joa Ebert <joae...@gmail.com> wrote:
I am currently implementing strong mode in defrac. Everything went smooth so far but I am experiencing an error I can't explain.
The following works as expected:

(function() {
"use strong";
class A {
  static neu() {
    new B()
  }
  constructor() {
    new B()
  }
}

class B {
  constructor() { print("B"); }
}
A.neu(); //B
new A(); //B
})();

But for some reason I get a ReferenceError when running a more complex example.

Mutually recursive class definitions are currently fine if:

1. The class declarations are in a single group, not interrupted by other declarations [counter example: class A { m(){new B} }; let x; class B {}].

2. All forward references are only inside methods [counter example: class A extends B {}; class B{}].

3. All (direct or indirect) backward references in the forward-referenced class are inside methods [counter example: class A { m(){new B} }; class B extends A {}].

Your more complex example probably violates at least one of these.

That said, we intend to relax the last point to allow direct occurrences in the extends clause, but nothing else, like e.g. suggested by Sébastien Doeraene [so there would only be counter examples like: class A { m(){new B} }; class B extends f(A) {}; /* or */ class A { m(){new B} }; class B { [A](){} }].

Also, the scoping checks aren't fully implemented yet in V8, so you might still encounter some cases that are allowed although they shouldn't be (especially when scoping crosses function boundaries).

Hope that helps.

/Andreas

d8 --strong-mode --harmony_arrow_functions app.js
app.js:105: ReferenceError: In strong mode, declaring variable 'java_lang_Throwable' before its use is required
if(e0 instanceof java_lang_Throwable) {
                 ^^^^^^^^^^^^^^^^^^^
ReferenceError: In strong mode, declaring variable 'java_lang_Throwable' before its use is required

The source file causing the issue is attached. Compiling it with Traceur works so I don't suspect a syntax error causing the issue.
I'm on V8 commit 83321b0


Best,
Joa

--
You received this message because you are subscribed to the Google Groups "Strengthen JS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to strengthen-j...@googlegroups.com.
To post to this group, send email to streng...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/strengthen-js/b4bf8084-1bd0-4457-af74-40038512b5fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andreas Rossberg

unread,
Jun 1, 2015, 8:53:31 AM6/1/15
to Joa Ebert, streng...@googlegroups.com
[Sorry for the late reply, btw, everybody's on holidays over here.]
Reply all
Reply to author
Forward
0 new messages