pyret-lang icon indicating copy to clipboard operation
pyret-lang copied to clipboard

Type aliases and cross-module information

Open jpolitz opened this issue 3 years ago • 0 comments

provide-alias.arr:

use context essentials2020
provide: type Name end
type Name = String

include-alias.arr:

use context essentials2020
include file("provide-alias.arr")
x :: Name = "a"

Running with the type-checker on results in Cannot find type binding for type-bind(bind-origin(srcloc("file:///Users/joe/src/pyret-lang/include-alias.arr", 2, 0, 17, 2, 33, 50), builtin("file:///Users/joe/src/pyret-lang/provide-alias.arr"), false, "file:///Users/joe/src/pyret-lang/provide-alias.arr", s-type-global("String")), tb-type-let, s-atom("Name", 3), tb-typ(t-name(module-uri("file:///Users/joe/src/pyret-lang/provide-alias.arr"), s-type-global("String"), builtin("file:///Users/joe/src/pyret-lang/provide-alias.arr"), false)))

(Actually, it may also fail at flatness with Unknown type key: String)

Both of these are symptomatic of the same issue; I bring up the TC as the primary bug because in flatness it's easy to bottom out with “don't know if this annotation is flat when checked” but the TC ought to work.

This is related to this program:

provide-alias-with-rename.arr:

use context essentials2020
provide: type String as Name end

And this second version has the right information. A vague description of the problem (I'm trying to get more details) is that the String coming from the include (implicit from use context) is being treated as a local definition when it's resolved in the context of type Name = ..... Then when we resolve the alias for Name, the resolver has a record that Name from provide-alias.arr is an alias for String from.... provide-alias.arr, instead of the original URI going back through essentials2021 to global (where it's actually exported as a datatype).

jpolitz avatar Sep 07 '21 17:09 jpolitz