-
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
Transparent inline codes causing compiler assertion error during pickling tree phase #18151
Comments
Runnng with checking try/i18151b.scala after phase typer
-- Warning: try/i18151b.scala:5:17 ---------------------------------------------
5 | println(tmplStr(el("div") >> "hello world"))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|symbol i18151b$package$._$el$proxy1 is defined at least twice in different parts of AST |
The problem seems to be regarding the inline parameter in transparent inline methods, as deleting the inline modifications allows compiler to run and produce properly inlined code. Meanwhile, according to the document "inline parameters have call semantics equivalent to by-name parameters but allow for duplication of the code in the argument." Would it be possible that the duplication of code due to the inline parameter led to the warning "symbol i18151b$package$._$el$proxy1 is defined at least twice in different parts of AST"? |
Mimimizedcase class El[A](val attr: String, val child: String)
transparent inline def tmplStr(inline t: El[Any]): String =
inline t match
case El(attr, child) => attr + child
def test: Unit = tmplStr {
val el = El("1", "2")
El[Any](el.attr, null)
} |
Minimization//> using option -Xprint:typer
case class El[A](attr: String, child: String)
transparent inline def inlineTest(): String =
inline {
val el: El[Any] = El("1", "2")
El[Any](el.attr, el.child)
} match
case El(attr, child) => attr + child
def test: Unit = inlineTest()
The issue is that |
Only the last expression of the block is considered as the inlined scrutinee. Otherwise we may not reduce as much as we should. We also need to make sure that side effects and bindings in the scrutinee are not duplicated. Fixes scala#18151
Only the last expression of the block is considered as the inlined scrutinee. Otherwise we may not reduce as much as we should. We also need to make sure that side effects and bindings in the scrutinee are not duplicated. Fixes scala#18151
Only the last expression of the block is considered as the inlined scrutinee. Otherwise we may not reduce as much as we should. We also need to make sure that side effects and bindings in the scrutinee are not duplicated. Inlined are converted into blocks to be able to apply the previous semantics without breaking the tree source files. Fixes #18151
Compiler version
3.3.0
Minimized code
in core/Tmpl.scala
in Main.scala
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: