lang/interpret_test/TestAstFunc2/test-monomorphic-lambda-arg.txtar
raw| 1 | -- main.mcl -- |
| 2 | import "fmt" |
| 3 | # $id could theoretically have type func(int) int or func(str) str, but it |
| 4 | # can't be both because it is bound to a lambda parameter, which must have a |
| 5 | # single type. |
| 6 | $use_polymorphically = func($id) { |
| 7 | fmt.printf("%d %s", $id(42), $id("hello")) |
| 8 | } |
| 9 | test "test1" { |
| 10 | anotherstr => $use_polymorphically(func($x) {$x}), |
| 11 | } |
| 12 | -- OUTPUT -- |
| 13 | # err: errUnify: unify error with: param(id): type error: int != str |