Skip to content

Commit 49f73c3

Browse files
committed
Add more complex tests
1 parent f2d7dae commit 49f73c3

File tree

3 files changed

+54
-6
lines changed

3 files changed

+54
-6
lines changed

compiler-core/src/type_/tests/errors.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -749,10 +749,10 @@ fn module_could_not_unify6() {
749749
}
750750

751751
#[test]
752-
fn module_could_not_unify_let_binding_annotation_follow_up() {
752+
fn module_could_not_unify_let_binding_annotation_follow_up1() {
753753
assert_module_error!(
754754
"
755-
pub fn main() {
755+
fn main() {
756756
let x: String = 5
757757
let y: Int = x
758758
let z: String = x
@@ -761,6 +761,24 @@ pub fn main() {
761761
);
762762
}
763763

764+
#[test]
765+
fn module_could_not_unify_let_binding_annotation_follow_up2() {
766+
assert_module_error!(
767+
"
768+
fn main() {
769+
let assert #(
770+
a,
771+
[[_, ..] as b, ..],
772+
_ as c
773+
): #(String, List(List(Int)), String) = #(1, [[\"Hello\"]], 3)
774+
775+
let d: String = a <> c
776+
let e: List(Int) = [0, ..b]
777+
}
778+
"
779+
);
780+
}
781+
764782
#[test]
765783
fn module_could_not_unify7() {
766784
assert_module_error!("fn main() { let assert 5 = \"\" }");
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
---
22
source: compiler-core/src/type_/tests/errors.rs
3-
assertion_line: 748
4-
expression: "\npub fn main() {\n let x: String = 5\n let y: Int = x\n let z: String = x\n}\n"
5-
snapshot_kind: text
3+
expression: "\nfn main() {\n let x: String = 5\n let y: Int = x\n let z: String = x\n}\n"
64
---
75
----- SOURCE CODE
86

9-
pub fn main() {
7+
fn main() {
108
let x: String = 5
119
let y: Int = x
1210
let z: String = x
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
source: compiler-core/src/type_/tests/errors.rs
3+
expression: "\nfn main() {\n let assert #(\n a, \n [[_, ..] as b, ..], \n _ as c\n ): #(String, List(List(Int)), String) = #(1, [[\"Hello\"]], 3)\n\n let d: String = a <> c\n let e: List(Int) = [0, ..b]\n}\n"
4+
---
5+
----- SOURCE CODE
6+
7+
fn main() {
8+
let assert #(
9+
a,
10+
[[_, ..] as b, ..],
11+
_ as c
12+
): #(String, List(List(Int)), String) = #(1, [["Hello"]], 3)
13+
14+
let d: String = a <> c
15+
let e: List(Int) = [0, ..b]
16+
}
17+
18+
19+
----- ERROR
20+
error: Type mismatch
21+
┌─ /src/one/two.gleam:7:45
22+
23+
7 │ ): #(String, List(List(Int)), String) = #(1, [["Hello"]], 3)
24+
^^^^^^^^^^^^^^^^^^^^
25+
26+
Expected type:
27+
28+
#(String, List(List(Int)), String)
29+
30+
Found type:
31+
32+
#(Int, List(List(String)), Int)

0 commit comments

Comments
 (0)