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.

Wrong compiler error message while using contextual functions

See original GitHub issue

Compiler version

Example is at 3.0.0 but the problem still exists for the newest master (commit b3ade17)

Minimized code

class I:
  def runSth: Int = 1

abstract class A:
  def myFun(op: I ?=> Unit) =
    op(using I())
    1

class B extends A
  
@main def hello: Unit = 
  
  B().myFun {
    val res = summon[I].runSth
    org.junit.Assert.assertEquals("", 1, res, "asd")
    // org.junit.Assert.assertEquals("", 1, res)
    println("Hello!")
  }


Output

[error] -- Error: /home/aratajczak/Dokumenty/Praca/Scala/compiler-bug/src/main/scala/Main.scala:14:23 
[error] 14 |    val res = summon[I].runSth
[error]    |                       ^
[error]    |no implicit argument of type I was found for parameter x of method summon in object Predef
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 0 s, completed 25 cze 2021, 16:08:49

Expectation

Error should point to wrong assertEquals dispatch instead of no implicit argument of type I. However, if we change commented line, Program succeedes

[info] running hello 
Hello!
[success] Total time: 0 s, completed 25 cze 2021, 16:09:29

I think it only exists for calling Java functions, however for scala function it returns BOTH no implicit and None of the overloaded alternatives of method assertEquals in object Assert with types errors which is somehow more correct. I’ll link clean repo with reproduction.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
oderskycommented, Dec 5, 2021

Was exp:intermediate a joke?

1reaction
oderskycommented, Jun 28, 2021

Further minimized without the junit dependency:

class I:
  def runSth: Int = 1

abstract class A:
  def myFun(op: I ?=> Unit) =
    op(using I())
    1

class B extends A

def assertEquals(x: String, y: Int, z: Int): Unit = ()

@main def hello: Unit =

  B().myFun {
    val res = summon[I].runSth
    assertEquals("", 1, res, "asd")
    println("Hello!")
  }
Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding and fixing compiler and linker errors
How to fix common compiler and linker errors in C++.
Read more >
c# - Wrong overload giving compiler error - Stack Overflow
In each case, it seems that the compiler becomes unable to determine which overload to use when it is being passed a reference...
Read more >
On Compiler Error Messages: What They Say and ... - Hindawi
In this paper, we focus on compiler error messages. First, related literature is reviewed and the problem placed in the context of the...
Read more >
Compiler Error C2672 - Microsoft Learn
In this article​​ The compiler could not find an overloaded function that matches the specified function. No function was found that takes ...
Read more >
SML/NJ Error Messages
This error message indicates how the parser attempted to "repair" the input (from a file foo.sml), and in this case indicates that the...
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