brownplt / pyret-lang

The Pyret language.
Other
1.07k stars 111 forks source link

type definition leads to odd errors #1677

Open shriram opened 1 year ago

shriram commented 1 year ago

Writing

type Key = String

in definitions runs fine. You can also write

s :: Key = "x"

in definitions and it's available in interactions. But writing

y :: Key = "x"

in interactions produces an internal error:

"Could not find type Key on module definitions://"

If you stick entirely to interactions, you can write both the type declaration and its uses in interactions.

But if you write the type declaration in definitions, run, and then enter it again in interactions, you don't get a duplicate definition error; instead, you again get the above "could not find" error.

shriram commented 1 year ago

Initially reported by jiad on Discord:

https://discord.com/channels/926326973209391144/926326973746270311/1051101136972693504

asolove commented 1 year ago

Interestingly, if you switch CPO from running untyped to running with types, then this works in the REPL fine:

Untyped (breaks):

image

Typed (works):

image

Perhaps we're throwing away some of the type info from the definitions window when running untyped?