Skip to content

Missing parameter type in inferring the type of the parameter of expanded function: #18521

Open
@MaYosy

Description

@MaYosy

Discussed in #18516

Originally posted by MaYosy September 5, 2023
compile failed:

@main def main(n: Int) = (time compose fib(_))(n)
[E081] Type Error: /home/mayosy/study/scala-fibonacci/src/TailRec.scala:12:20
|  (time compose fib(_))(n)
|                    ^
|   Missing parameter type
|
|   I could not infer the type of the parameter _$1 of expanded function:
|   _$1 => time compose fib(_$1).
|one error found

passed:

@main def main(n: Int) = 
  val f = fib(_)
  (time compose f)(n)
  // Or:
  // (time compose (fib(_)))(n)

Why? I am new in scala. :)

BTW, I find that the main function could't be:

@main def main = (x: String) => println(x)

but

@main def main(x: String) = println(x)

is ok (both compiled ok, but the former couldn't print anything)

:(

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions