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.

Weird Case Class Compiler Error with Inline Function

See original GitHub issue

Compiler version

Scala Version: 3.0.0 - 3.0.2 SBT: 1.5.2, 1.5.5

Example project here: https://github.com/cheeseng/scala3-case-class-inline-problem

Minimized code

class Test {
  inline def test(fun: => Any): Any = fun
  test {
    case class Pair[X, Y](
      x: X,
      y: Y,
    )
  }
}

Output

cheeseng@cheeseng-RAVEN:~/git/scala3-case-class-inline-problem$ sbt clean compile
[info] welcome to sbt 1.5.2 (GraalVM Community Java 1.8.0_292)
[info] loading project definition from /home/cheeseng/git/scala3-case-class-inline-problem/project
[info] loading settings for project root from build.sbt ...
[info] set current project to scala3-simple (in build file:/home/cheeseng/git/scala3-case-class-inline-problem/)
[info] Executing in batch mode. For better performance use sbt's shell
[success] Total time: 0 s, completed May 18, 2021 10:31:40 AM
[info] compiling 1 Scala source to /home/cheeseng/git/scala3-case-class-inline-problem/target/scala-3.0.0/classes ...
[error] -- Error: /home/cheeseng/git/scala3-case-class-inline-problem/src/main/scala/Test.scala:3:2 
[error] 3 |  inline def test(fun: => Any): Any = fun
[error]   |  ^
[error]   |bad parameter reference Pair.this.X at inlining
[error]   |the parameter is type X in class Pair but the prefix (Pair.this : Pair[X, Y])
[error]   |does not define any corresponding arguments.
[error]   |idx = 0, args = List()
[error] 4 |  test {
[error] 5 |    case class Pair[X, Y](
[error] 6 |      x: X,
[error] 7 |      y: Y,
[error] 8 |    )
[error] 9 |  }
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed May 18, 2021 10:31:43 AM

Expectation

The code should compile without error.

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
cheesengcommented, Oct 29, 2021

@nicolasstucki @TomasMikula Fyi I updated the example project to use Scala 3.1.0 but unfortunately it still encounters the same problem:

The example project is at:

https://github.com/cheeseng/scala3-case-class-inline-problem

2reactions
cheesengcommented, Sep 11, 2021

@nicolasstucki @TomasMikula Fyi I updated the example project to use Scala 3.0.2 but unfortunately it still encounters the same problem.

The example project is at:

https://github.com/cheeseng/scala3-case-class-inline-problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this inline class member function in C++ giving me an ...
The error in logic of using inline in the declarations for the statically linked library is that we assume that the compiler will...
Read more >
F5 is horribly wrong. You should ALWAYS declare your ...
inline is just like static, it means the function or the variable is an internal linkage. That's nonsense, it doesn't mean internal linkage...
Read more >
Weird template specialization errors - Microsoft Q&A
I managed to create a minimal example showing the problem : ... This file doesn't compile using visual studio 2019,2022. gcc and clang...
Read more >
Inline Functions In C - The Green End Organisation
GNU C (and some other compilers) had inline functions long before standard C introduced them (in the 1999 standard); this page summarizes the...
Read more >
Inline Function - an overview | ScienceDirect Topics
In these cases, the compiler treats the inline function as a regular function. However, a more serious problem occurs when the compiler itself...
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