Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typeof check output on DottyJS is incorrect #9785

Closed
djspiewak opened this issue Sep 13, 2020 · 0 comments
Closed

Typeof check output on DottyJS is incorrect #9785

djspiewak opened this issue Sep 13, 2020 · 0 comments

Comments

@djspiewak
Copy link

Discovered this as part of trying to port Cats Effect 3's build to DottyJS on 0.27.0-RC1 (SJS 1.2.0). Rough minimization:

if (js.typeOf(js.Dynamic.global.setImmediate) == Undefined) {

(this is part of PolyfillExecutionContext btw)

On Scala 2.13.3 (SJS 1.2.0), this line results in the following:

if (($as_T((typeof setImmediate)) === this.Lcats_effect_unsafe_PolyfillExecutionContext$__f_Undefined)) {

Which is exactly what I would expect. However, on 0.27.0-RC1 we get the following:

if (($as_T((typeof (0, setImmediate))) === this.Lcats_effect_unsafe_PolyfillExecutionContext$__f_Undefined)) {

This obviously doesn't return "undefined" when setImmediate is in fact undefined, meaning that the test is failed and we end up in a code path that isn't expected. This was discovered with Gecko and setImmediate (which is only available on NodeJS 0.9+ and Edge 10+), but it should be reproducible with almost anything.

@sjrd sjrd self-assigned this Sep 13, 2020
sjrd added a commit to dotty-staging/dotty that referenced this issue Sep 14, 2020
…ase.

This requires two things:

- make sure that `SelectStatic` does not expand references to
  global scopes, and
- when compiling `js.typeOf(globalRef)`, emit a
  `JSTypeOfGlobalRef(_)` instead of a
  `JSUnaryOp(typeof, JSGlobalRef(_))`.
sjrd added a commit to dotty-staging/dotty that referenced this issue Sep 14, 2020
…ase.

This requires two things:

- make sure that `SelectStatic` does not expand references to
  global scopes, and
- when compiling `js.typeOf(globalRef)`, emit a
  `JSTypeOfGlobalRef(_)` instead of a
  `JSUnaryOp(typeof, JSGlobalRef(_))`.
sjrd added a commit to dotty-staging/dotty that referenced this issue Sep 14, 2020
…ase.

This requires two things:

- make sure that `SelectStatic` does not expand references to
  global scopes, and
- when compiling `js.typeOf(globalRef)`, emit a
  `JSTypeOfGlobalRef(_)` instead of a
  `JSUnaryOp(typeof, JSGlobalRef(_))`.
sjrd added a commit to dotty-staging/dotty that referenced this issue Sep 14, 2020
…ase.

This is basically a forward port of the changes in the upstream commit
scala-js/scala-js@b2634ea
sjrd added a commit to dotty-staging/dotty that referenced this issue Sep 14, 2020
…ase.

This is basically a forward port of the changes in the upstream commit
scala-js/scala-js@b2634ea
@sjrd sjrd added this to the 3.0.0-M1 milestone Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants