You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type pretty-printer omits parentheses around by-name params, writing => A => B instead of (=> A) => B #6434
$ ./qbin/scala
Welcome to Scala version 2.10.0-20120925-012651-d6a933c4f5 (JavaHotSpot(TM) 64-BitServerVM, Java1.6.0_35).
Type in expressions to have them evaluated.
Type:help for more information.
scala>deff(x: =>Int):Int= x
f: (x: =>Int)Int
scala> f _
res0:=>Int=>Int= <function1>
Note: d6a933c4f5 is a local commit on top of ffaa3cb89edc1407c99c89f36248358c16887fe7 from 2.10.x, but it's just a small change:
@Blaisorblade said (edited on Sep 30, 2012 6:03:34 PM UTC):
=> A => B is a valid type, just the wrong one. Right-associativity makes that equal to => (A => B) (I'd file a separate bug otherwise), while we want a different type, (=> A) => B; hence omitting parentheses changes the type. The REPL output below suggests that => A => B is indeed right-associative as expected:
scala>valv: ((=>Int) =>Int) = f _
v:=>Int=>Int= <function1>
scala>valv: (=> (Int=>Int)) = f _
<console>:1:error: no by-name parameter typeallowed here
valv: (=> (Int=>Int)) = f _
^
scala>valv: (=>Int=>Int) = f _
<console>:1:error: no by-name parameter typeallowed here
valv: (=>Int=>Int) = f _
^
Activity
scabug commentedon Sep 27, 2012
Imported From: https://issues.scala-lang.org/browse/SI-6434?orig=1
Reporter: @Blaisorblade
Assignee: @JamesIry
Affected Versions: 2.9.2, 2.10.0
scabug commentedon Sep 30, 2012
@jsuereth said:
while the () is useful, I don't think this is actually a bug, more an improvement. IIRC, => A => B => C is a valid function type.
scabug commentedon Sep 30, 2012
@Blaisorblade said (edited on Sep 30, 2012 6:03:34 PM UTC):
=> A => B is a valid type, just the wrong one. Right-associativity makes that equal to => (A => B) (I'd file a separate bug otherwise), while we want a different type, (=> A) => B; hence omitting parentheses changes the type. The REPL output below suggests that => A => B is indeed right-associative as expected:
scabug commentedon Jan 23, 2013
@adriaanm said:
James, care to put some more parens in our types? (Because we like parens.)
scabug commentedon Jan 23, 2013
@JamesIry said:
scala/scala#1958