-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Scala.js: Concatenating a Char and String causes assertion failure #13518
Labels
Comments
Thanks for the report. Could you please provide a more complete reproduction? Out of its context, |
Thank you Sébastien for your fast reply! This was the more complete minimum reproduction I could get. object FooBar {
def baz(mySeq: Seq[String]) = mySeq.map(':' + _)
} This also causes the crash for me: object FooBar {
def baz(mySeq: Seq[String]) = mySeq.map(i => ':' + i)
} This also crashes: object FooBar {
def baz(mySeq: Seq[String], x: String) = 'a' + x
} Weirdly enough, this doesn't crash... object FooBar {
def baz(mySeq: Seq[String]) = 'a' + "B"
} |
edwardcwang
added a commit
to edwardcwang/scalatags
that referenced
this issue
Sep 14, 2021
There is a bug in the dotty compiler? scala/scala3#13518 scalatags.js[3.0.1,1.7.0].compile java.lang.AssertionError: assertion failed scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11) dotty.tools.backend.sjs.JSCodeGen.genStringConcat(JSCodeGen.scala:2487) dotty.tools.backend.sjs.JSCodeGen.genPrimitiveOp(JSCodeGen.scala:2098)
sjrd
changed the title
ScalaJS: concatenating a Char and String causes assertion failure
Scala.js: Concatenating a Char and String causes assertion failure
Sep 15, 2021
sjrd
added a commit
to dotty-staging/dotty
that referenced
this issue
Sep 15, 2021
Sometimes, the argument string's `tpe` can be `TermRef`, in which case it is not directly a ref to `StringClass`. That was triggering the assertion. The assertions and the calls to `makePrimitiveBox` have actually not been needed for a long time. The IR supports the arguments to a `String_+` operator to be of any type. So we fix the issue by removing all of that and directly emitting the `String_+`.
sjrd
added a commit
that referenced
this issue
Sep 16, 2021
Fix #13518: Scala.js: fix primitive + string when the string is a TermRef.
lolgab
added a commit
to com-lihaoyi/scalatags
that referenced
this issue
Dec 2, 2021
## Changes * Add Mima to check how much we break binary compatibility. * Update Mill to version `0.9.10` and fix build deprecations * Add `scalaMajorVersion` in buildInfoMembers since Scala 3 represents types wrapped inside `()` in error messages. * Explicitly apply implicit function `ev: A => Frag` in various implicit classes (like `SeqFrag`) since Scala 3 doesn't apply implicitly. * Remove `protected[this] val RawFrag: Companion[RawFrag]` and `protected[this] val StringFrag: Companion[StringFrag]` since they break variance and Scala 3 is much less permissive with variance. Overriding them with strictier types in subclasses result in compiler errors. Since this was the only use case of `Companion` I removed it as well. Also I failed to represent `Companion` in Scala 3 since it uses [different signatures for `unapply`](https://dotty.epfl.ch/docs/reference/changed-features/pattern-matching.html) * Add explicit types to all `implicit` fields as required by Scala 3. * Replace `def +(other: Any): String` in class `String` with String interpolator since it is not supported in Scala 3 * Make all abstract members in `Tags.scala`, `Tags2.scala` and `SvgTags.scala` `def`s instead of `val`s since Scala 3 doesn't support overriding an abstract `val` member with a `lazy val` as Scalatags does. * Move the `SourceClasses` class and its companion object to the version specific code. Since it is the only code using macros. * Updated tests to not use the `* -` utest syntax. Also not supported in Scala 3. * Move objects used in tests to be stable and not defined in the utest macro. Without this change the Scala 3 version doesn't compile. ## Commits * Update build system for Scala 3 * Initial Scala 3 (dotty) port * Only use str-to-str concatenation There is a bug in the dotty compiler? scala/scala3#13518 scalatags.js[3.0.1,1.7.0].compile java.lang.AssertionError: assertion failed scala.runtime.Scala3RunTime$.assertFailed(Scala3RunTime.scala:11) dotty.tools.backend.sjs.JSCodeGen.genStringConcat(JSCodeGen.scala:2487) dotty.tools.backend.sjs.JSCodeGen.genPrimitiveOp(JSCodeGen.scala:2098) * Bump to Scala 3.0.0 * wip * Use string interpolation instead of `+` * Gitignore /.bsp from Mill BSP * Remove space in quoted start * Reduce duplicated code and fix some compilation error * Remove some lazy vals and revert renames * Most code compiles * All code compiling now * Fix macro to use declaredFields * Remove pprint * Remove empty companion objects * Remove old comment * Avoid to define lazy val Frags * Revert some changes not necessary for Scala 3 * Revert formatting change * Remove unused import * Revert spurious change * Remove spurious import * Refactor filter for ScalaJS versions Co-authored-by: Sakib Hadžiavdić <sake92@users.noreply.github.com> Co-authored-by: Edward Wang <edward.c.wang@compdigitec.com> Co-authored-by: Sakib Hadžiavdić <sake92@users.noreply.github.com>
olsdavis
pushed a commit
to olsdavis/dotty
that referenced
this issue
Apr 4, 2022
…a TermRef. Sometimes, the argument string's `tpe` can be a `TermRef`, in which case it is not directly a ref to `StringClass`. That was triggering the assertion. The assertions and the calls to `makePrimitiveBox` have actually not been needed for a long time. The IR supports the arguments to a `String_+` operator to be of any type. So we fix the issue by removing all of that and directly emitting the `String_+`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compiler version
3.0.1
Minimized code
Output
Expectation
It should not crash with an assertion error. Worked around it by using only Strings:
":" + _
The text was updated successfully, but these errors were encountered: