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

Open
scabug opened this Issue Nov 9, 2014 · 4 comments

Comments

Projects
None yet
3 participants
@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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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;

@scabug scabug added this to the Backlog milestone Apr 7, 2017

@SethTisue SethTisue removed quickfix labels Feb 5, 2018

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