Skip to content
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

java.lang.UnsupportedOperationException: Position.start on NoPosition #12453

Closed
lancewalton opened this issue Aug 29, 2021 · 6 comments
Closed

Comments

@lancewalton
Copy link

reproduction steps

using Scala 2.13.6

case class Foo[T]()

object Foo extends App {
  val foo = Foo[IO[()]]
}

problem

The problem is that () is a value, not a type. the val line should say:

  val foo = Foo[IO[Unit]]()

So it was my dodgy code that caused the problem to exhibit. But I'd expect the compiler to issue an error, not throw an Exception.

@SethTisue SethTisue reopened this Aug 29, 2021
@SethTisue
Copy link
Member

SethTisue commented Aug 29, 2021

I get a normal error as expected:

% scalac -version
Scala compiler version 2.13.6 -- Copyright 2002-2021, LAMP/EPFL and Lightbend, Inc.
% scalac S.scala
S.scala:4: error: Illegal literal type (), use Unit instead
  val foo = Foo[IO[()]]
                   ^
1 error

@lancewalton
Copy link
Author

Hmmm... odd. I'll investigate some more.

@lancewalton
Copy link
Author

OK. I've confirmed that if I do this in a clean project (defining IO as trait IO[_]), I get a compiler error. I'll try to determine why I'm getting the stack trace in my real project...

@som-snytt
Copy link

Note trait IO[_] is not legal syntax. scala/scala#9712

I thought () is just the literal type, but I see that exactly a year ago I contributed the exclusion scala/scala#9183

Dotty says

scala> val c = C[IO[()]]()
1 |val c = C[IO[()]]()
  |               ^
  |               '=>' expected, but ']' found

Maybe the underlying issue has to do with incremental compilation and case companions, just a guess.

@SethTisue
Copy link
Member

@lancewalton did you have a chance to get back to this?

@lancewalton
Copy link
Author

No, sorry. I never got a chance to investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants