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

Instances cannot be resolved if the type contains holes #3157

Closed
lukaszcz opened this issue Nov 7, 2024 · 2 comments · Fixed by #3293
Closed

Instances cannot be resolved if the type contains holes #3157

lukaszcz opened this issue Nov 7, 2024 · 2 comments · Fixed by #3293

Comments

@lukaszcz
Copy link
Collaborator

lukaszcz commented Nov 7, 2024

For example, type-checking

main : Nat :=
  for (acc := 0) ((x, _) in [1, 1; 2, 2; 3, 3]) {
    acc + x
  };

gives the error:

No trait instance found for: Foldable (List (Pair Nat Nat)) (Pair Nat _)

This is a more fundamental problem with not being able to backtrack on unification in the type checker.

@paulcadman
Copy link
Collaborator

We should tackle this after #3209

@paulcadman paulcadman modified the milestones: 0.6.9, Sanalejo Dec 2, 2024
@lukaszcz lukaszcz modified the milestones: Sanalejo , 0.6.10 Jan 21, 2025
@lukaszcz lukaszcz self-assigned this Jan 21, 2025
@lukaszcz
Copy link
Collaborator Author

I think I can solve this by replacing holes with instance metavariables during instance search, and then only unifying them at the end when the instance is found.

lukaszcz added a commit that referenced this issue Jan 22, 2025
* Closes #3157
* During instance search, the holes are now treated like meta-variables
-- they match anything. The holes are not unified during instance
search, but on success all dangling meta-variables are replaced by fresh
holes which later need to be filled by the type-checker. In rare
situations, the type-checker might not be able to fill them even though
instance resolution succeeded (then we get the "Unable to infer the
hole" error).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants