question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RequireMsg compile-time error message escaping code context

See original GitHub issue

This 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:open
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
soronpocommented, Mar 15, 2022

Actually this kind of looks like a Scalac bug, but maybe as a result of that tampering with @implicitNotFound via macros.

0reactions
tribbloidcommented, Mar 20, 2022

… Sorry the last option is out of context & doesn’t apply to your case. The implicit error will always write over the previous error

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found