-
Notifications
You must be signed in to change notification settings - Fork 170
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
"Use of unknown variable" ICE #1950
Comments
Interesting. Should this program be type correct? I don't think so. There is no way for the type checker to know the type of the |
I'm not sure I understand. It seems like the compiler is able to infer the type of a branch based on the type of the other branches -- why not here? For example, in: type option 'a = #None | #Some(a)
entry test =
if true
then #None
else (#Some(5): option i32) My assumption was that the size parameter would be carried over to the other branch. |
The false branch has type def gen () : ?[n].[n]i32 =
let n = 0
in replicate n 0i32
def empty [n] 't (_: [n]t): [0][n]t =
[]
entry main b: [0][]i32 =
if b
then []
else empty(gen ()) And the solution is the same: add a type annotation to disambiguate. The solution I'm cooking up will actually provide a slightly misleading type error, because it will try to set |
Actually, one root cause of this bug is that when a constructor like |
It's precisely this rule that the program violates, and which the type checker did not catch. |
Makes sense, thank you for your detailed explanation! |
This bug occurs on
0.24.3
and c304a93 (latest commit):Error:
The text was updated successfully, but these errors were encountered: