-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes incorrect variable names in type mismatch errors (#1313)
* Fixes incorrect variable names in type mismatch errors In certain cases, it was possible for a row type variable to alias an existing type variable, causing confusing error messages. This commit fixes that by tracking type variable kinds together with their IDs. Fixes #1312 Co-authored-by: Matthew Healy <matthew.healy@tweag.io> * Pass VarId and VarKind separately for nicer call sites * Update test expectations --------- Co-authored-by: Matthew Healy <matthew.healy@tweag.io>
- Loading branch information
Showing
9 changed files
with
95 additions
and
44 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
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
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
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
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
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
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
7 changes: 7 additions & 0 deletions
7
tests/snapshot/inputs/errors/unification_variable_aliasing.ncl
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,7 @@ | ||
# capture = 'stderr' | ||
# command = [] | ||
|
||
# Regression test for #1312 | ||
let f : forall a. (forall r. { bla : Bool, blo : a, ble : a; r } -> a) = fun r => if r.bla then (r.blo + 1) else r.ble | ||
in (f { bla = true, blo = 1, ble = 2, blip = 'blip } : Number) | ||
|
15 changes: 15 additions & 0 deletions
15
tests/snapshot/snapshots/snapshot__error_stderr_unification_variable_aliasing.ncl.snap
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,15 @@ | ||
--- | ||
source: tests/snapshot/main.rs | ||
expression: err | ||
--- | ||
error: incompatible types | ||
┌─ [INPUTS_PATH]/errors/unification_variable_aliasing.ncl:5:98 | ||
│ | ||
5 │ let f : forall a. (forall r. { bla : Bool, blo : a, ble : a; r } -> a) = fun r => if r.bla then (r.blo + 1) else r.ble | ||
│ ^^^^^ this expression | ||
│ | ||
= Expected an expression of type `a` | ||
= Found an expression of type `Number` | ||
= These types are not compatible | ||
|
||
|