Regression since 3.0.0-M3: Issue with inlining in transparent macros
See original GitHub issueCompiler version
3.0.0-RC3
Minimized code
object TransparentMacro:
transparent inline def apply(inline n: Int): Any = ${applyImpl('n)}
def applyImpl(n: Expr[Int])(using Quotes): Expr[Any] = if n.valueOrError > 0 then n else Expr("negative")
// In other file
object Test extends App:
inline def x = -5
println(TransparentMacro(x))
Output
Compilation error:
|Expected a known value.
[error] |
[error] |The value of: com.example.Test.x
[error] |could not be extracted using scala.quoted.FromExpr$PrimitiveFromExpr@4eae616
[error] | This location contains code that was inlined from Test.scala:23
Expectation
The above code compiles in 3.0.0-M3. It should also compile in 3.0.0-RC3.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Blog - Scala 3 - EPFL
We are happy to announce the release of Scala 3.0.0-M3. ... normal parameters after given parameters, inline givens specialization and more.
Read more >Inline | Macros in Scala 3
Inlining is a common compile-time metaprogramming technique, typically used to achieve performance optimizations. As we will see, in Scala 3, the concept of ......
Read more >Using the GNU Compiler Collection
5.36 An Inline Function is As Fast As a Macro . ... is unable to read from a pipe; but the GNU assembler...
Read more >Using the GNU Compiler Collection (GCC) - Index of
This built-in function returns a pointer to data describing how to perform a call with the same arguments as were passed to the...
Read more >changes - SWIG.org
SWIG python objects were being freed after the corresponding SWIG module information ... errors in Guile wrappers - regression introduced in swig-3.0.11.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ahhh, wasn’t aware of that, and yeah, it works with
transparent inline def x = -5
. Well, thanks a lot for your help!That explains it:
transparent inline
are expanded in an earlier phase. Thus at the time when expandingapply
,x
is not yet inlined. If you addtransparent
toinline def x = -5
, it may work as well.