-
Notifications
You must be signed in to change notification settings - Fork 21
Nested case class construction fails with "no legal prefix" #4859
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
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4859?orig=1 |
@paulp said: object O {
new C().CC()
}
class C() {
case class CC()
} |
Commit Message Bot (anonymous) said: |
@paulp said: object O {
// error: C is not a legal prefix for a constructor
C().CC()
// but this works.
D().DD()
}
case class C() {
case class CC()
}
case class D() {
class DD()
object DD {
def apply() = new DD()
}
} |
@adriaanm said: |
Matthew Farwell (mfarwell) said: object Test {
case class B() { case class C() }
var b = B()
var c = b.C()
} This bug is now fixed in version scala-2.10.0.r25798-b20111007023456. |
Stefan Wehr (stefanwehr) said: |
Matthew Farwell (mfarwell) said: |
David Leuschner (dleuschner) said: I just realized that this bug was already present before 2.9.1 was released on 2011-08-31 and the NPE was even fixed before it was released but it is still present in the current stable release. We as a company (factis research) are considering adopting Scala as the main language. We have a Haskell server in production and one of the reasons of choosing Scala over Haskell is that we're hoping that there's a focus on "industrial strength" quality, tools and commercial support. We got the impression that there's a big community using Scala not only for fun but for commercial services. With this bug the compiler dies without helpful notice and you can't compile or deploy your product and have to revert to bisecting your code to detect what might be giving Scala hiccups and guess how to "rephrase" the code to make it work. This can cost hours of work and is very frustrating. The bug has already been fixed three months ago. I'm wondering when the next stable Scala I think it would be good to catch all exceptions and give as much information as possible to the user about what happened (like the source file that was currently being processed). With that information you have a chance to guess what might be the problem. GHC outputs a nice message ("the impossible happened") and asks you to report the bug. That's better than just a NPE because now you at least know it's a bug in the compiler (and not sbt or other tools). |
@paulp said: |
David Leuschner (dleuschner) said: My suggestion is to "fix" the problem by giving a helpful message to the user (such as: known bug in the compiler, see issue #4859 for suggested workaround"). That shouldn't be much work in the compiler but can save users time and gives a much better impression. Of course a "real fix" would be better but I'd prefer an earlier release with a message that improves the user experience. |
@paulp said: object O {
// error: C is not a legal prefix for a constructor
C().CC()
} (From the example in my most recent comment containing code.) |
@paulp said: |
@adriaanm said: |
@retronym said: |
@retronym said: |
This is a bug, affected versions (at least) 2.9.0.1, 2.9.1.RC1 and 2.10 (a recent nightly)
Try to compile the following:
Will result in
The text was updated successfully, but these errors were encountered: