10000 Trees in statement position may have incorrect types · Issue #4442 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

Trees in statement position may have incorrect types #4442

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

Closed
gzm0 opened this issue Feb 26, 2021 · 2 comments · Fixed by #4439
10000
Closed

Trees in statement position may have incorrect types #4442

gzm0 opened this issue Feb 26, 2021 · 2 comments · Fixed by #4439
Assignees
Labels
bug Confirmed bug. Needs to be fixed.
Milestone

Comments

@gzm0
Copy link
Contributor
gzm0 commented Feb 26, 2021

See: #4439 (comment)

@gzm0 gzm0 added the bug Confirmed bug. Needs to be fixed. label Feb 26, 2021
@gzm0 gzm0 self-assigned this Feb 26, 2021
@gzm0
Copy link
Contributor Author
gzm0 commented Feb 26, 2021

There seem to be two independent issues:

When transforming If, we do not set the proper result type based on isStat:

https://github.com/scala-js/scala-js/blob/master/compiler/src/main/scala/org/scalajs/nscplugin/GenJSCode.scala#L2314-L2316

Other transformations have this pattern:

val tpe =
  if (isState) jstpe.NoType
  else toIRType(tree.tpe)

Adding this fixes some of the IR checking errors.

The other issue is in JS constructor export generation: The export machinery post transforms the trees generated by genExportMethod. In that process, it moves trees that were meant for expression position (overload dispatch and forwarder calling) into statement position. While it adjusts the inner trees, it doesn't adjust the types of the surrounding trees.

I have not yet been able to fix this problem (it seems that post-transforming trees is unwise, an approach that simply generates the right trees upfront seems better).

@gzm0
Copy link
Contributor Author
gzm0 commented Mar 14, 2021

An update on this: I'm currently working on improving how JS exporter generation works. This takes quite some time unfortunately.

gzm0 added a commit to gzm0/scala-js that referenced this issue May 25, 2021
Instead of post-transforming the trees generated by GenJSExport, we
re-factor the right parts and generated the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js#4442).
gzm0 added a commit to gzm0/scala-js that referenced this issue May 25, 2021
Instead of post-transforming the trees generated by GenJSExport, we
re-factor the right parts and generated the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js#4442).
gzm0 added a commit to gzm0/scala-js that referenced this issue May 26, 2021
Instead of post-transforming the trees generated by GenJSExport, we
re-factor the right parts and generated the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js#4442).
gzm0 added a commit to gzm0/scala-js that referenced this issue May 26, 2021
Instead of post-transforming the trees generated by GenJSExport, we
re-factor the right parts and generated the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js#4442).
gzm0 added a commit to gzm0/scala-js that referenced this issue May 26, 2021
Instead of post-transforming the trees generated by GenJSExport, we
re-factor the right parts and generated the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js#4442).
gzm0 added a 10000 commit to gzm0/scala-js that referenced this issue May 30, 2021
Instead of post-transforming the trees generated by GenJSExport, we
re-factor the right parts and generated the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js#4442).
@gzm0 gzm0 added this to the v1.6.0 milestone May 30, 2021
sjrd pushed a commit to gzm0/scala-js that referenced this issue Jun 4, 2021
…osition

In statement position, they must always be typed as NoType, since
their children might be typed as such.

We condition the deserialization hack introduced in the parent
commit so that it only applies to old code.
sjrd pushed a commit to gzm0/scala-js that referenced this issue Jun 4, 2021
…osition

In statement position, they must always be typed as NoType, since
their children might be typed as such.

We condition the deserialization hack introduced in the parent
commit so that it only applies to old code.
@gzm0 gzm0 linked a pull request Jun 5, 2021 that will close this issue
sjrd pushed a commit to gzm0/scala-js that referenced this issue Jun 7, 2021
…osition

In statement position, they must always be typed as NoType, since
their children might be typed as such.

We condition the deserialization hack introduced in the parent
commit so that it only applies to old code.
@sjrd sjrd closed this as completed in #4439 Jun 7, 2021
sjrd added a commit to dotty-staging/dotty that referenced this issue Jul 14, 2021
Instead of post-transforming the trees generated by JSExportsGen, we
refactor the right parts and generate the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js/scala-js#4442).

Forward port of
scala-js/scala-js@8093f28
sjrd added a commit to dotty-staging/dotty that referenced this issue Jul 14, 2021
Instead of post-transforming the trees generated by JSExportsGen, we
refactor the right parts and generate the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js/scala-js#4442).

Forward port of
scala-js/scala-js@8093f28
smarter pushed a commit to dotty-staging/dotty that referenced this issue Aug 16, 2021
Instead of post-transforming the trees generated by JSExportsGen, we
refactor the right parts and generate the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js/scala-js#4442).

Forward port of
scala-js/scala-js@8093f28
smarter pushed a commit to dotty-staging/dotty that referenced this issue Aug 17, 2021
Instead of post-transforming the trees generated by JSExportsGen, we
refactor the right parts and generate the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js/scala-js#4442).

Forward port of
scala-js/scala-js@8093f28
sjrd added a commit to dotty-staging/dotty that referenced this issue Aug 23, 2021
Instead of post-transforming the trees generated by JSExportsGen, we
refactor the right parts and generate the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js/scala-js#4442).

Forward port of
scala-js/scala-js@8093f28
olsdavis pushed a commit to olsdavis/dotty that referenced this issue Apr 4, 2022
Instead of post-transforming the trees generated by JSExportsGen, we
refactor the right parts and generate the proper trees right away.

This was neccessary to give the generated trees the right
type (partial scala-js/scala-js#4442).

Forward port of
scala-js/scala-js@8093f28
sjrd added a commit to sjrd/scala-js that referenced this issue Dec 14, 2024
Recent changes have all but removed the distinction between
statements and expressions in the IR. Notably:

* bb4f6da
  Allow Return arg to be a void if the target Labeled is a void.
* cdcff99
  Rename NoType to VoidType and print it as "void".

Therefore, it made no sense anymore that `Transformer.transform`
had an `isStat` argument. In fact, the first of the two commits
mentionned above semi-broke the semantics of that argument anyway.
Moreover, `isStat` was never *used* in our codebase (only forwarded
everywhere for no reason).

The only exception was a deserialization hack for IR <= 1.5. This
one was already hacking around the fact the IR produced back then
was not well-typed. See scala-js#4442 for context.

We now remove that parameter everywhere. It makes the
deserialization hack a bit more verbose, but everything else
becomes simpler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug. Needs to be fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0