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

Wrong error message when using copy on case class with by-name parameter in second parameters list #7879

Closed
scabug opened this issue Sep 26, 2013 · 7 comments · Fixed by scala/scala#10770
Assignees
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) language spec
Milestone

Comments

@scabug
Copy link

scabug commented Sep 26, 2013

/***
scalaVersion := "2.10.3-RC3"
 
*/
object Main extends App {
  case class UploadingFile(fid: String, name: String, length: Long, uploaded: Boolean)(onFileProcessingEnd: => String)
  val f = UploadingFile("", "", 0, true)("")
  println(f.copy(uploaded = true)())
 
}
[error] /tmp/rendererAQzTia6Gxe/src/main/scala/test.scala:8: value copy is not a member of Main.UploadingFile
[error]   println(f.copy(uploaded = true)())
while without by-nameness the error is more clear
[error] /tmp/rendererAQzTia6Gxe/src/main/scala/test.scala:8: not enough arguments for expression of type (onFileProcessingEnd: String)Main.UploadingFile.
[error] Unspecified value parameter onFileProcessingEnd.
[error]   println(f.copy(uploaded = true)())

btw why there is no default arguments now?
i've seen https://github.com/scala/scala-dist/pull/52/files but not sure what prompted that

@scabug
Copy link
Author

scabug commented Sep 26, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7879?orig=1
Reporter: @OlegYch
Affected Versions: 2.10.2, 2.10.3-RC3

@scabug
Copy link
Author

scabug commented Sep 26, 2013

@paulp said:
The error message is correct. There's no copy method being generated.

"while without by-nameness the error is more clear"

That's because it's a different error. In that case there is a copy method.

@scabug
Copy link
Author

scabug commented Sep 26, 2013

@OlegYch said:
thanks, Paul, you're right
i guess we should rephrase the issue as "no copy method with by-name parameters" ?

@scabug
Copy link
Author

scabug commented Sep 26, 2013

@paulp said:
I think the repeated parameter part means what it says - repeated parameters in any parameter list including the first mean you don't get a copy method. That by-name parameters suppress the copy method is likely just undocumented. (That's why I didn't close this.)

@scabug
Copy link
Author

scabug commented Sep 27, 2013

@lrytz said:
what prompted the change was #5009 and #5118

i see that we don't generate copy when there's a by-name (https://github.com/scala/scala/blob/master/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala#L186), but i don't remember why.. it should be either changed, or added to the spec

@SethTisue SethTisue added this to the Backlog milestone Mar 2, 2018
@nogurenn
Copy link

nogurenn commented Jun 3, 2020

In 2.11.12, 2.12.11, and 2.13.2 REPL, I get the following (with variation in error format, but same exact message).

scala> case class UploadingFile(fid: String, name: String, length: Long, uploaded: Boolean)(onFileProcessingEnd: => String)
class UploadingFile

scala> val f = UploadingFile("", "", 0, true)("")
val f: UploadingFile = UploadingFile(,,0,true)

scala> println(f.copy(uploaded = true)())
                 ^
       error: value copy is not a member of UploadingFile
                      ^
       error: not found: value uploaded

@SethTisue SethTisue added fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) and removed good first issue labels Jun 3, 2020
@SethTisue
Copy link
Member

it should be either changed, or added to the spec

I don't think we want to spec this, as Dotty does not have the restriction:

scala> f.copy(uploaded = true)("")
val res1: UploadingFile = UploadingFile(,,0,true)

and I've removed the "good first issue" label since the other choice, namely lifting the restriction in Scala 2, is probably neither easy nor especially important to tackle

thanks, @nogurenn, for taking a look 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) language spec
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants