-
Notifications
You must be signed in to change notification settings - Fork 120
Open
Description
Hello,
The following code does not type check:
var lst = empty
lst := link(1, lst)
print(1 + lst.first)
It complains that lst has type (List<?-1> % is-empty) and thus has no field named first.
On a related topic, I suspect that Pyret's type checker does not catch property the problem of polymorphic references (see the history of ML). For instance, the following code does type check:
fun head<a>(l :: List<a>) -> a:
cases (List<a>) l:
| empty => raise("head")
| link(x, _) => x
end
end
var lst = empty
lst := link(1, lst)
print(head(lst))
fun foo(n :: Number) -> Number: n end
lst := link(foo, lst)
print(head(lst)(1))
but it should not. Removing the second assignment leads to a runtime error (trying to apply something which is not a function).
Metadata
Metadata
Assignees
Labels
No labels