pyret-lang
pyret-lang copied to clipboard
unbound identifier has history and weird output
Consider this program:
include tables
type Key = String
cities =
table: code :: Key, name :: Key
row: "PVD", "Providence"
row: "EWR", "Newark"
row: "SFO", "San Francisco"
end
flights =
table: origin :: Key, destination :: Key
row: "EWR", "SFO"
row: "SFO", "EWR"
row: "PVD", "EWR"
row: "EWR", "PVD"
end
fun neighbors(k :: Key) -> List<Key>:
matches = sieve flights using origin: origin == k end
# matches.get-column("destination")
extract destination from matches end
end
check:
neighbors("PVD") is [list: "EWR"]
neighbors("SFO") is [list: "EWR"]
neighbors("EWR").to-set() is [list: "PVD", "SFO"]
end
I run this in CPO without the type-checker on.
The third test has an error. If I then type list-to-set in the REPL, I get

The reference to Key is really weird. If instead I put the same name in the definitions and click Run, I get a conventional unbound identifier error.
Something stranger is going on. After that failing test, I get this output for ALL expressions in the REPL?!?
See #1665
Something worse – contexts are making types that are just aliases (not constructed types) behave strangely at the REPL (in CPO).
There are some small reproductions, like just declaring type Num = Number and then trying to use the REPL. Thankfully since it's so bad it'll probably be straightforward to fix.
Don't we have tests for that? (And if we do, why aren't they failing...?)