Skip to content

Fix #5115: Apply the StoreModule hack to JSConstructorDef from 1.8. #5116

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

Merged
merged 1 commit into from
Jan 15, 2025

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Jan 15, 2025

Before 1.11, the body of JSConstructorDefs was a straight list of trees. We have a hack that extracts the three parts of a structured JSConstructorBody: beforeSuper, superCall and afterSuper.

In 1.18, we introduced a separate hack to ensure that afterSuper starts with a StoreModule instruction.

Unfortunately, we did not apply the latter hack on the result of the former. This means our deserializer incorrectly reads JS module classes from before 1.11.

This commit makes sure to also apply the hack in that situation.

Unfortunately, this does not come with automated tests. We do not have any non-native JS module class in our standard library, which is currently our only source of old IR for backward compatibility tests.


Locally tested with the following hello world:

object HelloWorld {
  def main(args: Array[String]): Unit = {
    println(org.log4s.log4sjs.ExceptionInfo.NoException)
  }
}

and the dependency

set helloworld.v2_13/libraryDependencies += "org.log4s" % "log4s_sjs1_2.13" % "1.10.0"

Unfortunately we don't have the infrastructure to test this in CI. @gzm0 Any suggestion?

…m 1.8.

Before 1.11, the body of `JSConstructorDef`s was a straight list of
trees. We have a hack that extracts the three parts of a structured
`JSConstructorBody`: `beforeSuper`, `superCall` and `afterSuper`.

In 1.18, we introduced a separate hack to ensure that `afterSuper`
starts with a `StoreModule` instruction.

Unfortunately, we did not apply the latter hack on the result of
the former. This means our deserializer incorrectly reads JS module
classes from before 1.11.

This commit makes sure to also apply the hack in that situation.

Unfortunately, this does not come with automated tests. We do not
have any non-native JS module class in our standard library, which
is currently our only source of old IR for backward compatibility
tests.
@sjrd sjrd requested a review from gzm0 January 15, 2025 16:56
Copy link
Contributor

@gzm0 gzm0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we don't have the infrastructure to test this in CI. @gzm0 Any suggestion?

I don't think there is anything we can do, lest we want to build the infrastructure to simulate old IR or publish some fake packages for testing specifically :-/

@sjrd sjrd merged commit 6203902 into scala-js:main Jan 15, 2025
3 checks passed
@sjrd sjrd deleted the fix-jsmoduleclass-hack-aftersuper-from-1.8 branch January 15, 2025 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants