This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Need Help Understanding & Correcting "missing parameter type for expanded function"

2 replies
Randall R Schulz
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.

Hi,

I'm trying to understand and resolve these errors:

/dar/rho/src/rho/alg/Traversals.scala
Error:Error:line (324)error: missing parameter type for expanded function
((x$12) => ExpressionCursor(expr, next.node.pos.ahead(), x$12, next.node.pol)) _, next.node.pol)))

The code is:

traversal ++ connected.map(TraversalAction(ahead, ExpressionCursor(expr, next.node.pos.ahead(), _, next.node.pol)))

A similar fragment:

traversal ++ next.at.asInstanceOf[FunctionTerm].args.map(ExpressionCursor(expr, next.pos.ahead(), _, next.pol))

Does not prodduce this error.

TraversalAction and ExpressionCursor are a case-class constructors.

I gather the problem has to do with the anonymous function parameter
being nested inside the second constructor the erroneous case, but
don't know how to resolve it.

Randall Schulz

Luc Duponcheel
Joined: 2008-12-19,
User offline. Last seen 34 weeks 3 days ago.
Re: Need Help Understanding & Correcting "missing parameter ty
I hope that the following explanation helps:   placeholder syntax like: someFunction(someArg, _, otherArg) is equivalent with: (arg) => someFunction(someArg, arg, otherArg) if the type inferencer does not have enough context information to infer the type, say A, of arg, then you have to help it as follows: (arg: A) => someFunction(someArg, arg, otherArg)   -- sometimes you have to give the inferencer a helping hand
  Luc
On Mon, Mar 23, 2009 at 3:08 PM, Randall R Schulz <rschulz@sonic.net> wrote:
Hi,

I'm trying to understand and resolve these errors:

/dar/rho/src/rho/alg/Traversals.scala
   Error:Error:line (324)error: missing parameter type for expanded function
     ((x$12) => ExpressionCursor(expr, next.node.pos.ahead(), x$12, next.node.pol)) _, next.node.pol)))


The code is:

   traversal ++ connected.map(TraversalAction(ahead, ExpressionCursor(expr, next.node.pos.ahead(), _, next.node.pol)))


A similar fragment:

   traversal ++ next.at.asInstanceOf[FunctionTerm].args.map(ExpressionCursor(expr, next.pos.ahead(), _, next.pol))

Does not prodduce this error.


TraversalAction and ExpressionCursor are a case-class constructors.

I gather the problem has to do with the anonymous function parameter
being nested inside the second constructor the erroneous case, but
don't know how to resolve it.


Randall Schulz



--
  __~O
 -\ <,
(*)/ (*)

reality goes far beyond imagination

Randall R Schulz
Joined: 2008-12-16,
User offline. Last seen 1 year 29 weeks ago.
Re: Need Help Understanding & Correcting "missing parameter typ

On Monday March 23 2009, Randall R Schulz wrote:
> Hi,
>
> I'm trying to understand and resolve these errors:
>
> /dar/rho/src/rho/alg/Traversals.scala
> Error:Error:line (324)error: missing parameter type for expanded function
> ((x$12) => ExpressionCursor(expr, next.node.pos.ahead(), x$12, next.node.pol)) _, next.node.pol)))
>
>
> The code is:
>
> traversal ++ connected.map(TraversalAction(ahead, ExpressionCursor(expr, next.node.pos.ahead(), _, next.node.pol)))
>
> ...
>
> TraversalAction and ExpressionCursor are a case-class constructors.
>
> I gather the problem has to do with the anonymous function parameter
> being nested inside the second constructor the erroneous case, but
> don't know how to resolve it.

On a hunch, I changed the code thusly:

traversal ++ connected.map(arg => TraversalAction(ahead, ExpressionCursor(expr, next.node.pos.ahead(), arg, next.node.pol)))

And it compiled. What did I do?

Randall Schulz

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland