Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Records with other records as fields fail to type check when imported #139

Open
s-zeng opened this issue Jan 3, 2025 · 0 comments
Open

Comments

@s-zeng
Copy link

s-zeng commented Jan 3, 2025

Structs that work and type check properly in a single file fail to work properly when imported. Reproducing example below:

Tested on commit 78169ab on master

# a.star
StructA = record(val=str)
StructB = record(a=StructA)
# b.star
load("a.star", "StructA")
load("a.star", "StructB")
myB = StructB(a=StructA(val="foo"))
print(myB)
# bNoImports.star
StructA = record(val=str)
StructB = record(a=StructA)
myB = StructB(a=StructA(val="foo"))
print(myB)
$ pwd
/Users/simonzeng/repos/starlark-rust/starlark_bin
$ cargo run -- bNoImports.star 
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
     Running `/Users/simonzeng/repos/starlark-rust/target/debug/starlark bNoImports.star`
record[StructB](a=record[StructA](val="foo"))
1 files, 0 errors, 0 warnings, 0 advices, 0 disabled
$ cargo run -- b.star
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s
     Running `/Users/simonzeng/repos/starlark-rust/target/debug/starlark b.star`
Traceback (most recent call last):
  * b.star:3, in <module>
      myB = StructB(a=StructA(val="foo"))
error: Value `record[StructA](val="foo")` of type `record` does not match the type annotation `StructA` for argument `a`
 --> b.star:3:7
  |
3 | myB = StructB(a=StructA(val="foo"))
  |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
1 files, 1 errors, 0 warnings, 0 advices, 0 disabled
Error: Failed with 1 errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant