-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Typechecker (MGU.hs): fix unergonomic checking of function applications
When checking a function call, and it's wrong, we expect the error to be reported as the arguments having the wrong type, not the function being the wrong type for the arguments we provided. Therefore, check an application by matching the argument against the function, not the function against the arguments. In particular, we should generate a fresh argument type and unify it with the type of the function, _then_ unify it with the argument expression, not the other way around. Someone stepped on this today internally and it was confusing all around. Add a test case in test_type_errors.
- Loading branch information
1 parent
01c4ca8
commit eca889f
Showing
3 changed files
with
27 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Loading file "err002.saw" | ||
err002.saw:5:44-5:57: Type mismatch. | ||
Mismatch of type constructors. Expected: String but got ([]) | ||
internal:1:1-1:7: The type String arises from this type annotation | ||
err002.saw:5:44-5:57: The type [LLVMType] arises from the type of this term | ||
|
||
Expected: String | ||
Found: [LLVMType] | ||
|
||
within "spec" (err002.saw:4:5-4:9) | ||
|
||
FAILED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// llvm_alias takes a string, pass it a list of types instead | ||
// (user meant to use llvm_struct_type and used llvm_struct, | ||
// which is a deprecated name for llvm_alias) | ||
let spec = do { | ||
input <- llvm_fresh_var "x" (llvm_alias [llvm_int 32]); | ||
llvm_execute_func [llvm_term input]; | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters