Skip to content

Commit a79cdaf

Browse files
committed
Add more complex tests
1 parent 8feba88 commit a79cdaf

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
@@ -744,10 +744,10 @@ fn module_could_not_unify6() {
744744
}
745745

746746
#[test]
747-
fn module_could_not_unify_let_binding_annotation_follow_up() {
747+
fn module_could_not_unify_let_binding_annotation_follow_up1() {
748748
assert_module_error!(
749749
"
750-
pub fn main() {
750+
fn main() {
751751
let x: String = 5
752752
let y: Int = x
753753
let z: String = x
@@ -756,6 +756,24 @@ pub fn main() {
756756
);
757757
}
758758

759+
#[test]
760+
fn module_could_not_unify_let_binding_annotation_follow_up2() {
761+
assert_module_error!(
762+
"
763+
fn main() {
764+
let assert #(
765+
a,
766+
[[_, ..] as b, ..],
767+
_ as c
768+
): #(String, List(List(Int)), String) = #(1, [[\"Hello\"]], 3)
769+
770+
let d: String = a <> c
771+
let e: List(Int) = [0, ..b]
772+
}
773+
"
774+
);
775+
}
776+
759777
#[test]
760778
fn module_could_not_unify7() {
761779
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)