Dotty: 0.19: Function currying is being flagged as requiring ? instead of _ but should not.

Created on 24 Sep 2019  Â·  9Comments  Â·  Source: lampepfl/dotty

bug

All 9 comments

Can you provide an example ?

blah.flatMap:
  ("blah",_).toUpload(arg)

is being flagged as requiring ? instead of _. In 0.18, it worked fine, etc.

Please provide a full example that compiles, combined with the exact error message you get from the compiler, we have more than 400 issues so we cannot afford to spend time doing this ourselves.

@smarter I have alot of currying in my code so this blocks me from 0.19+ dotty upgrade unless I recode all of these. Do you think a fix for this would make it in to 0.20 or 0.19.1?

@aappddeevv What we are after is

  • a minimal code example in the issue, as opposed to a link to some project.
  • the exact error message that was issued.

That would help our workflow for fixing bugs. Thanks!

Thanks for looking into this:

def (p: (String,Int)) curryme: String =
  println(s"curryme: ${p._1}, ${p._2}")
  p._1

object Main 
  def main(args: Array[String]): Unit =
    // use postfix on curryme  
    val x1 =
      Seq(1,2,3).map:
        ("static", _).curryme
    // this gives an error in 0.18 that says it cannot infer the parameter type
    val x2 =
      Seq(1,2,3).map:
        curryme(("static", _))
    // std syntax, compiles and runs fine
    val x3 = Seq(1,2,3).map(i => ("static", i).curryme)

0.19.0-RC1 error

[warn] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:10:20: `_` is deprecated for wildcard arguments of types: use `?` instead
[warn]         ("static", _).curryme
[warn]                    ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:10:22: end of statement expected but '.' found
[error]         ("static", _).curryme
[error]                      ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:10:23: ';' expected, but identifier found
[error]         ("static", _).curryme
[error]                       ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:14:16: end of statement expected but '(' found
[error]         curryme(("static", _))
[error]                ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:14:17: ';' expected, but '(' found
[error]         curryme(("static", _))
[error]                 ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:9:7: Found:    (Int => Any) => Seq[Any]
[error] Required: (String("static"), ?)
[error]       Seq(1,2,3).map:
[error]       ^
[warn] one warning found
[error] 5 errors found
[error] (Compile / compileIncremental) Compilation failed

Here's the flags I have set:

  scalacOptions ++= Seq(
"-indent"
,  "-strict"
        ,"-language:strictEquality"

),

0.18.1 error:

[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:14:28: Missing parameter type
[error] 
[error] I could not infer the type of the parameter _$2.
[error]         curryme(("static", _))
[error]                            ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed

Oh, now it becomes clear: The : as replacement for {...} is enabled
only under -Yindent-colon in Dotty 0.19. So the compiler thought it was
seeing a type after map :, not an argument. That's where the weird
warning came from.

So for the moment, compile with -Yindent-colon. Maybe we'll bring it back
into the standard, that depends how the discussions go.

On Sun, Sep 29, 2019 at 2:03 PM aappddeevv notifications@github.com wrote:

The link is to a project that has the full example, and only that example,
that compiles per the request. Here's the exact error message that was
issued in that project and the code from that project.

def (p: (String,Int)) curryme: String =
println(s"curryme: ${p._1}, ${p._2}")
p._1
object Main
def main(args: Array[String]): Unit =
// use postfix on curryme
val x1 =
Seq(1,2,3).map:
("static", _).curryme
// this does not generate the warning, use std func apply for fun
val x2 =
Seq(1,2,3).map:
curryme(("static", _))
// std syntax, compiles and runs fine
val x3 = Seq(1,2,3).map(i => ("static", i).curryme)

[warn] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:10:20: _ is deprecated for wildcard arguments of types: use ? instead
[warn] ("static", _).curryme
[warn] ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:10:22: end of statement expected but '.' found
[error] ("static", _).curryme
[error] ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:10:23: ';' expected, but identifier found
[error] ("static", _).curryme
[error] ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:14:16: end of statement expected but '(' found
[error] curryme(("static", _))
[error] ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:14:17: ';' expected, but '(' found
[error] curryme(("static", _))
[error] ^
[error] /home/me/proj/languages/scala/dotty-issue-7305/src/main/scala/Main.scala:9:7: Found: (Int => Any) => Seq[Any]
[error] Required: (String("static"), ?)
[error] Seq(1,2,3).map:
[error] ^
[warn] one warning found
[error] 5 errors found
[error] (Compile / compileIncremental) Compilation failed

Here's the flags I have set:

scalacOptions ++= Seq("-indent"
, "-strict"
,"-language:strictEquality"

),

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/lampepfl/dotty/issues/7305?email_source=notifications&email_token=AAGCKVRHAMU4XWITEBNA2PDQMCKQXA5CNFSM4IZ6XSOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD73SV5I#issuecomment-536292085,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAGCKVW7KXIODA342SN6F4TQMCKQXANCNFSM4IZ6XSOA
.

--
Prof. Martin Odersky
LAMP/IC, EPFL

That did it! "-Yindent-colons".

Was this page helpful?
0 / 5 - 0 ratings