| [#257] | project: compiler | priority: low | category: bug | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Michel | Martin | fixed | 2003-12-09 15:29:34.0 | |
| subject | Eta expansion / call-by-name incompatibility | |||
| code |
object Main {
def sayhello(): Unit = { System.out.println("hello "); };
def f1(x: Unit): Unit = ();
def f2(x: Unit)(y: Unit): Unit = ();
def f(def x: Unit) = {
f1(x);
f2(x);
}
def main(args: Array[String]): Unit = {
f(sayhello())
}
}
|
|||
| what happened | Only one "hello" is printed. The problem is a bad interaction between the eta-expander and call-by-name. The eta\ -expander tries to be smart and doesn't create an eta$n variable for the "x" passed to f2 because it thinks it i\ s pure (my guess). This is correct only if "x" is not a call-by-name parameter, which is not the case here. |
|||
| what expected | Two "hello" messages. | |||
| [back to overview] | ||||
| Martin edited on 2004-01-05 17:08:53.0 |