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

REPL can't handle (A*) => A #8971

Closed
scabug opened this issue Nov 9, 2014 · 5 comments
Closed

REPL can't handle (A*) => A #8971

scabug opened this issue Nov 9, 2014 · 5 comments
Assignees
Labels
Milestone

Comments

@scabug
Copy link

scabug commented Nov 9, 2014

There is a compilation error (only in the REPL) in the following example, where none should be:

scala> val f: (Int*) => Int = _.size
<console>:5: error: type mismatch;
 found   : Int* => Int
 required: Seq[Int] => Int
  lazy val $result = f
                                          ^
@scabug
Copy link
Author

scabug commented Nov 9, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8971?orig=1
Reporter: @sschaef
Affected Versions: 2.11.4

@scabug
Copy link
Author

scabug commented Nov 9, 2014

@retronym said:
According to the spec,* is only allowed on method parameters. The compiler also allows them in function types, but the behaviour is unspecified. Personally, I'd like to disallow this.

@scabug
Copy link
Author

scabug commented Apr 19, 2015

Li Haoyi (lihaoyi) said:
This is fixed in the Ammonite REPL

@ val f: (Int*) => Int = _.size
f: Seq[Int] => Int = <function1>
@ f(1)
res2: Int = 1
@ f(1, 3, 4)
res3: Int = 3
@

@scabug
Copy link
Author

scabug commented Jan 16, 2017

@som-snytt said (edited on Jan 16, 2017 2:29:36 AM UTC):
Surprise,

$ scala
Welcome to Scala 2.12.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_111).
Type in expressions for evaluation. Or try :help.

scala> val f: (Int*) => Int = _.size
f: Int* => Int = $$Lambda$1042/1092382020@1687eb01

scala> f(1,2,3)
res0: Int = 3

// the relevant definitions:
// <stable> <accessor> def f: Int* => Int = $iw.this.f
// <stable> <accessor> lazy val $result: Seq[Int] => Int = $line1.$read.$iw.$iw.f;

@SethTisue
Copy link
Member

these days this gives "error: repeated parameters are only allowed in method signatures; use Seq instead" (including in Ammonite)

@SethTisue SethTisue modified the milestones: Backlog, 2.13.0 Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants