-
Notifications
You must be signed in to change notification settings - Fork 1.1k
"Compiler bug" when using constValue inside an inline method #12417
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
Comments
Sorry wrong key, adding details :) |
Ready :) |
This use case is too advances for object TestMacro {
inline def test1[CASE_CLASS <: Product](using m: Mirror.ProductOf[CASE_CLASS]): Unit =
${ code('m) }
def code[CASE_CLASS <: Product: Type](m: Expr[Mirror.ProductOf[CASE_CLASS]])(using Quotes): Expr[Unit] =
m match
case '{ $_ : Mirror { type MirroredElemLabels = t } } =>
quotes.reflect.report.error(s"Error: ${ Type.show[t] }", m)
'{}
} We have |
Ah, I though tuples of primitive types are allowed as well. I suppose the issue is then about the error message :) So to report user-friendly errors, which include the type/ label information, I have to resort to a macro, instead of using inline+Mirror? |
Hm reading your answer again, shouldn't
I'm getting a
|
That is #10315 |
Ah :) Indeed - so I suppose construction of an error message which is anything above a constant string means going to a macro. Though ... maybe I can call the macro from the inline branch? 🤔 I'll have to try that. Would you like me to close this issue as a duplicate, or keep it open to improve the error message? |
What could the error message have said that would have helped you understand the issue? |
E.g. "Not a constant: |
Although, maybe this is already covered by the second error, |
Oh, I missed that part. We should not emit the first error. |
Ah, I missed it because it is already fixed. I remember that issue. Now it fails with 13 | TestMacro.test1[A]
| ^^^^^^^^^^^^^^^^^^
|not a constant type: m$proxy1.MirroredElemLabels; cannot take constValue
| This location contains code that was inlined from Foo.scala:7 |
Awesome, thank you! :) |
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.0.0-RC3
Minimized code
This comes from an attempt to provide user-friendly error messages for inline derivations which use mirrors.
Output
Expectation
The text was updated successfully, but these errors were encountered: