Skip to content

Commit 9c9d964

Browse files
committed
Improve function return type error messages.
1 parent 688ff51 commit 9c9d964

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

crates/wac-parser/src/resolution/types.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -963,16 +963,16 @@ impl<'a> SubtypeChecker<'a> {
963963
let (expected, found) = self.expected_found(a, b);
964964
match (&expected.results, &found.results) {
965965
(Some(FuncResult::List(_)), Some(FuncResult::Scalar(_))) => {
966-
bail!("expected function with named results, found function with scalar result")
966+
bail!("expected function that returns a named result, found function with a single result type")
967967
}
968968
(Some(FuncResult::Scalar(_)), Some(FuncResult::List(_))) => {
969-
bail!("expected function with scalar result, found function with named results")
969+
bail!("expected function that returns a single result type, found function that returns a named result")
970970
}
971971
(Some(_), None) => {
972-
bail!("expected function with results, found function without results")
972+
bail!("expected function with a result, found function without a result")
973973
}
974974
(None, Some(_)) => {
975-
bail!("expected function without results, found function with results")
975+
bail!("expected function without a result, found function with a result")
976976
}
977977
(Some(FuncResult::Scalar(_)), Some(FuncResult::Scalar(_)))
978978
| (Some(FuncResult::List(_)), Some(FuncResult::List(_)))

crates/wac-parser/tests/resolution/fail/expected-result-named.wac.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ failed to resolve document
22

33
× mismatched instantiation argument `x`
44
├─▶ mismatched type for export `f`
5-
╰─▶ expected function with named results, found function with scalar result
5+
╰─▶ expected function that returns a named result, found function with a single result type
66
╭─[tests/resolution/fail/expected-result-named.wac:7:23]
77
6 │
88
7 │ let i = new foo:bar { x };

crates/wac-parser/tests/resolution/fail/expected-result-scalar.wac.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ failed to resolve document
22

33
× mismatched instantiation argument `x`
44
├─▶ mismatched type for export `f`
5-
╰─▶ expected function with scalar result, found function with named results
5+
╰─▶ expected function that returns a single result type, found function that returns a named result
66
╭─[tests/resolution/fail/expected-result-scalar.wac:7:23]
77
6 │
88
7 │ let i = new foo:bar { x };

crates/wac-parser/tests/resolution/fail/func-results-not-present.wac.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ failed to resolve document
22

33
× mismatched instantiation argument `x`
44
├─▶ mismatched type for export `f`
5-
╰─▶ expected function with results, found function without results
5+
╰─▶ expected function with a result, found function without a result
66
╭─[tests/resolution/fail/func-results-not-present.wac:7:23]
77
6 │
88
7 │ let i = new foo:bar { x };

crates/wac-parser/tests/resolution/fail/func-results-present.wac.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ failed to resolve document
22

33
× mismatched instantiation argument `x`
44
├─▶ mismatched type for export `f`
5-
╰─▶ expected function without results, found function with results
5+
╰─▶ expected function without a result, found function with a result
66
╭─[tests/resolution/fail/func-results-present.wac:7:23]
77
6 │
88
7 │ let i = new foo:bar { x };

0 commit comments

Comments
 (0)