facebook / starlark-rust

A Rust implementation of the Starlark language
Apache License 2.0
672 stars 53 forks source link

disambiguating record types defined in different files #120

Open johnynek opened 2 months ago

johnynek commented 2 months ago

I have some code like:

fn foo(v: Value) {
  let ty = Ty::of_value(v);
  let ident = ty.to_string();
  ...
}

And the motivation is that I am building a configuration system where I allow users to define new record types. But the issue comes when user in one file makes Foo = record() and another file makes Foo = record(). These are distinct types because they were defined in two separate files.

But the ty.to_string() in the above collides.

  1. is there currently a way I can disambiguate these two?
  2. if not, would you be open to a PR that allows inspecting the module id where the user type was defined, which should allow disambiguation.