RequireMsg compile-time error message escaping code context
See original GitHub issueThis is a short code snippet that demonstrates the problem:
import singleton.ops.RequireMsg
object RequireMsgSpike {
trait HasM {
type M = Int
}
trait Foo {
trait FF[T]
}
object Foo3 extends Foo {
implicit def ev3[T <: HasM](
implicit
r: RequireMsg[false, "Just Bad Type"]
): Set[FF[T]] = ???
}
object Foo4 extends Foo {
implicit def ev4[T <: HasM](
implicit
r: Int
): Set[FF[T]] = ???
}
implicitly[Set[Foo3.FF[HasM]]]
implicitly[Set[Foo4.FF[HasM]]]
}
error message:
[Error] /***/RequireMsgSpike.scala:34:13: Just Bad Type
[Error] /***/RequireMsgSpike.scala:35:13: Just Bad Type
The second implicit error message got corrupted by the first.
if you delete the first implicit line implicitly[Set[Foo3.FF[HasM]]]
, the error message goes back to normal:
[Error] /home/peng/git/shapesafe/core/src/test/scala/shapesafe/core/debugging/RequireMsgSpike.scala:35:13: could not find implicit value for parameter e: Set[shapesafe.core.debugging.RequireMsgSpike.Foo4.FF[shapesafe.core.debugging.RequireMsgSpike.HasM]] (No implicit view available from shapesafe.core.debugging.RequireMsgSpike.Foo4.FF[shapesafe.core.debugging.RequireMsgSpike.HasM] => Boolean.)
I vaguely remember that RequireMsg macro overwrites @ImplicitNotFound annotation to achieve its purpose, and this implementation is derived from shapeless. So I guess the easiest way for me is to try the following solution:
- try to reproduce it in shapeless
- if succeed, forward-port it to singleton-ops
- otherwise, file the same issue for shapeless, and try to write an original fix or circumvention
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
Top Results From Across the Web
Is there a way to provide custom compile error messages in ...
Say I am building a library and I want to provide certain custom compile time error messages to users. Is there a way...
Read more >compile time error messages : Java Glossary
This error often comes up in the context of the clone method which, without covariance, returns an Object reference not the specific type...
Read more >Compile-time operations - Scala 3
constValue is a function that produces the constant value represented by a type, or a compile time error if the type is not...
Read more >Modern C++ best practices for exceptions and error handling
In modern C++, in most scenarios, the preferred way to report and handle both logic errors and runtime errors is to use exceptions....
Read more >Compiler messages - IBM
nnnn: error message number; text: message which appears on the screen ... This compiler requires a runtime environment __librel() value of &1.
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 FreeTop 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
Top GitHub Comments
Actually this kind of looks like a Scalac bug, but maybe as a result of that tampering with
@implicitNotFound
via macros.… Sorry the last option is out of context & doesn’t apply to your case. The implicit error will always write over the previous error