Erik edited on 2003-09-10 17:20:18.0
|
Here is another example:
class P {
val Tuple1(Foo):Tuple1[Any => Any] = Tuple1((x:Any) => Foo(x));
val Tuple1(foo:(Any => Any)) = Tuple1((x:Any) => foo(x));
}
~/scala/bin/scalac P.scala
P.scala:2: not found: value Foo
val Tuple1(Foo):Tuple1[Any => Any] = Tuple1((x:Any) => Foo(x));
^
P.scala:2: not found: value Foo
val Tuple1(Foo):Tuple1[Any => Any] = Tuple1((x:Any) => Foo(x));
^
P.scala:2: object scala.Unit of type scala.Unit cannot be applied to ()
val Tuple1(Foo):Tuple1[Any => Any] = Tuple1((x:Any) => Foo(x));
^
P.scala:3: recursive value foo$ needs type
val Tuple1(foo:(Any => Any)) = Tuple1((x:Any) => foo(x));
^
four errors found
|
Erik edited on 2003-09-10 17:30:12.0
|
More readable version of my last comment:
Here is another case where the case is important:
~/scala/bin/scalac P.scala
P.scala:2: not found: value Foo
val Tuple1(Foo):Tuple1[Any => Any] = Tuple1((x:Any) => Foo(x));
^
P.scala:2: not found: value Foo
val Tuple1(Foo):Tuple1[Any => Any] = Tuple1((x:Any) => Foo(x));
^
P.scala:2: object scala.Unit of type scala.Unit cannot be applied to ()
val Tuple1(Foo):Tuple1[Any => Any] = Tuple1((x:Any) => Foo(x));
^
P.scala:3: recursive value foo$ needs type
val Tuple1(foo:(Any => Any)) = Tuple1((x:Any) => foo(x));
^
four errors found
|
Erik edited on 2003-09-10 17:31:34.0
|
And here is the code for the previous comment:
class P {
val Tuple1(Foo):Tuple1[Any => Any] = Tuple1((x:Any) => Foo(x));
val Tuple1(foo:(Any => Any)) = Tuple1((x:Any) => foo(x));
}
|
Burak edited on 2003-09-11 11:46:26.0
|
this is my fault.
according to p.30 and p.69, an arbitrary type may appear,
while I only parse type1 ( the "Any" ).
Now you get, so parsing works as expected
ga.scala:4: f is already defined as value f in class ga
val f: Any => Any = (x:Any) => f(x);
^
ga.scala:3: ambiguous reference to overloaded definition,
both value f$: (scala.Any) => scala.Any
and value f$: (scala.Any) => scala.Any
match expected type (scala.Any) => scala.Any
val f:(Any => Any) = (x:Any) => f(x);
^
two errors found
|
Martin edited on 2003-09-11 12:38:51.0
|
Unfortunately, it's not so easy. The existing grammar with
pattern = variable : Type1 is necessary to avoid ambiguities.
If we change it to pattern = variable : Type, we get the build problems Erik notoced. I am still looking for a solution.
|
Matthias edited on 2003-09-12 12:52:27.0
|
|
Martin edited on 2003-09-16 15:40:10.0
|
|