-
Notifications
You must be signed in to change notification settings - Fork 53
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
Typechecking infers incorrect types #2517
Comments
This is actually a bug with the new named arguments syntax. Just before having type constructor parameters for inductive types we never used type variables in constructors. |
Well, the bug is in the typechecker, both the new and old one, the named arguments syntax only exposes it. Running
This is still correct. The holes are incorrectly inferred, without taking scope into account. |
For the old typechecker, the following input exposes the bug:
|
@janmasrovira can you look at this? Is there some easy fix or this exposes a bigger issue with holes having no context? |
A simpler example without traits:
Running
Running
|
It seems like the problem is with not remembering the hole context. |
this could be related or the exact same problem as #2247 |
I guess we need to fix this before making use of type constructor inductive parameters. This bug gets exposed whenever there are record fields with implicit type arguments, which happens with |
This pr applies a number of fixes to the new typechecker. The fixes implemented are: 1. When guessing the arity of the body, we properly use the type information of the variables in the patterns. 2. When generating wildcards, we name them properly so that they align with the name in the type signature. 3. When compiling named applications, we inline all clauses of the form `fun : _ := body`. This is a workaround to #2247 and #2517 4. I've had to ignore test027 (Church numerals). While the typechecker passes and one can see that the types are correct, there is a lambda where its clauses have different number of patterns. Our goal is to support that in the near future (#1706). This is the conflicting lambda: ``` mutual num : Nat → Num := λ : Nat → Num {| (zero : Nat) := czero | ((suc n : Nat)) {A} := csuc (num n) {A}} ``` 5. I've added non-trivial a compilation test involving monad transformers.
Input:
Output after running
uvix dev internal typecheck ty1.juvix --print-result --new-typechecker
:In the fist
fmap
, the type variablesA
andB
are not bound, which later makes the translation from Internal to Core fail.The text was updated successfully, but these errors were encountered: