This lets us get the more correct lowercase versions of type kinds in error messages. (These match what the user would type.)
14 lines
422 B
Plaintext
14 lines
422 B
Plaintext
-- main.mcl --
|
|
import "fmt"
|
|
# $id could theoretically have type func(int) int or func(str) str, but it
|
|
# can't be both because it is bound to a class parameter, which must have a
|
|
# single type.
|
|
func use_polymorphically($id) {
|
|
fmt.printf("%d %s", $id(42), $id("hello"))
|
|
}
|
|
test "test1" {
|
|
anotherstr => use_polymorphically(func($x) {$x}),
|
|
}
|
|
-- OUTPUT --
|
|
# err: errUnify: unify error with: param(id): type error: int != str
|