You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The specific type of nested list doesn't seem to make a difference (Could be List List _, List List a, List List U64)
While in this minimal example the signature could just specifically be that of an empty list, in more complex examples a function could return either some actual nested list or just an empty list as a default case (which is how I came across this issue) and it breaks there as well. This is just an MRE.
Environment:
OS: Archlinux
Roc: roc nightly pre-release, built from commit 50ec8ef on Di 10 Dez 2024 09:02:17 UTC
The text was updated successfully, but these errors were encountered:
$ cargo run -- test repro.roc
Finished dev [unoptimized + debuginfo] target(s) in 0.24s
Running `target/debug/roc test repro.roc`
thread '<unnamed>' panicked at crates/compiler/mono/src/layout.rs:3297:69:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
^C
When I add parentheses around what should be the inner type of List _, everything type checks and roc test repro.roc passes.
The LSP currently thinks that the type of List List _ is List List, implying to me that we infer the type hole as a type variable that gets ignored or something.
Interestingly, if I change the type to List Str _ then the inferred type is List Str even without the parentheses, and everything works.
However, List Str Str also works, which shouldn't.
{} -> List is inferred as {} -> List a where a implements Eq (because of the == in the test)
So this looks like a bug where we are not validating the number of type args a type constructor gets. If it receives fewer args than expected, it sometimes infers a new variable, and sometimes doesn't leading to crashes like the one reported. Extra type args are seemingly ignored. I think the fix would involve us adding type arg amount constraining somewhere in roc_constrain.
Returning an empty list (
[]
) from a function that has a signature of returning a nested empty list crashes the compiler.Code example:
Expected behavior:
I'd expect an empty list to be a valid value for a list of lists.
Actual behavior:
Observations:
[[]]
instead works just fineList List _
,List List a
,List List U64
)Environment:
OS: Archlinux
Roc: roc nightly pre-release, built from commit 50ec8ef on Di 10 Dez 2024 09:02:17 UTC
The text was updated successfully, but these errors were encountered: