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

Dynamic field are ignored by the typechecker #2124

Open
yannham opened this issue Dec 16, 2024 · 0 comments
Open

Dynamic field are ignored by the typechecker #2124

yannham opened this issue Dec 16, 2024 · 0 comments

Comments

@yannham
Copy link
Member

yannham commented Dec 16, 2024

Describe the bug
Dynamic fields are just entirely ignored by the typechecker, which means we can write unsound code that will typecheck but fail at run time (including failing unexpectedly late because contracts issued from static types have been elided).

To Reproduce

$ nickel repl
> :tc (let x = 1 in {"%{x}" = 1, bar = false}) : {_ : Bool}
Ok: { _ : Bool }

Expected behavior
I expect that the typechecker correctly ensures that a record with dynamic fields is inferred/checker to be of type {_ : T} for some T and that the fields defined dynamically are actually checked against this type.

Additionally, I expect that the interpolated expressions to be checked to be of type String.

Environment

Additional context
I realized this as part of #2121. It's clear from the code that we don't visit dynamic fields at all. This is expected to be fixed by #2121, so not much to do on that front until then.

@yannham yannham self-assigned this Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant