Skip to content

Commit

Permalink
Reverse types in error message for struct field assign. (#1706)
Browse files Browse the repository at this point in the history
The types listed for the error messages when assigning the wrong type to
a struct field during construction were reversed.

This fixes that issue by swapping "actual" and "expected" the types.
  • Loading branch information
ScottCarda-MS authored Jul 8, 2024
1 parent a5e35bc commit ada0639
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions compiler/qsc_frontend/src/typeck/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,10 +925,10 @@ fn check_has_field(
match udts.get(id).and_then(|udt| udt.field_ty_by_name(&name)) {
Some(ty) => (
vec![Constraint::Eq {
expected: item,
actual: id
expected: id
.package
.map_or_else(|| ty.clone(), |package_id| ty.with_package(package_id)),
actual: item,
span,
}],
Vec::new(),
Expand Down
2 changes: 1 addition & 1 deletion compiler/qsc_frontend/src/typeck/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2244,7 +2244,7 @@ fn struct_cons_wrong_input() {
#25 88-124 "new Pair { First = 5.0, Second = 6 }" : UDT<"Pair": Item 1>
#30 107-110 "5.0" : Double
#33 121-122 "6" : Int
Error(Type(Error(TyMismatch("Double", "Int", Span { lo: 99, hi: 110 }))))
Error(Type(Error(TyMismatch("Int", "Double", Span { lo: 99, hi: 110 }))))
"#]],
);
}
Expand Down

0 comments on commit ada0639

Please sign in to comment.