-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add compiler diagnostic tests for majority of hir diagnostics
- Loading branch information
Showing
30 changed files
with
292 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
fn main() { | ||
let foo = new i32 {}; | ||
} |
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,11 @@ | ||
Error: sema::constructing_non_struct_type | ||
|
||
× cannot construct a non-struct type | ||
╭─[constructing-non-struct-type.eight:4:13] | ||
3 │ fn main() { | ||
4 │ let foo = new i32 {}; | ||
· ─────┬──── | ||
· ╰── the type i32 is not a struct type | ||
5 │ } | ||
╰──── | ||
|
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,9 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
struct Foo { | ||
bar: i32, | ||
} | ||
|
||
fn main() { | ||
let foo = new *Foo {}; | ||
} |
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,12 @@ | ||
Error: sema::constructing_pointer_type | ||
|
||
× cannot construct a pointer type | ||
╭─[constructing-pointer-type.eight:8:13] | ||
7 │ fn main() { | ||
8 │ let foo = new *Foo {}; | ||
· ─────┬───── | ||
· ╰── type *Foo is a pointer type and cannot be constructed | ||
9 │ } | ||
╰──── | ||
help: did you mean to construct the inner type? | ||
|
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,5 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
fn main() { | ||
let foo = *(1); | ||
} |
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,11 @@ | ||
Error: sema::dereference_of_non_pointer | ||
|
||
× type i32 is not a pointer type, and cannot be dereferenced | ||
╭─[dereference-of-non-pointer.eight:4:13] | ||
3 │ fn main() { | ||
4 │ let foo = *(1); | ||
· ──┬─ | ||
· ╰── i32 is not dereferenceable | ||
5 │ } | ||
╰──── | ||
|
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 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
intrinsic_fn get_i32() -> i32; | ||
|
||
fn main() { | ||
let dummy = get_i32(1); | ||
} |
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,11 @@ | ||
Error: sema::function_type_mismatch | ||
|
||
× function types do not take the same number of arguments | ||
╭─[function-type-mismatch.eight:6:15] | ||
5 │ fn main() { | ||
6 │ let dummy = get_i32(1); | ||
· ─────┬──── | ||
· ╰── the function has type fn() -> i32 | ||
7 │ } | ||
╰──── | ||
|
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,5 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
fn main(a: i32) { | ||
let b = a.foo; | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/ui/hir/invalid-field-reference-of-non-struct.eight.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,11 @@ | ||
Error: sema::invalid_field_reference_of_non_struct | ||
|
||
× type i32 is not a struct type and does not have fields | ||
╭─[invalid-field-reference-of-non-struct.eight:4:13] | ||
3 │ fn main(a: i32) { | ||
4 │ let b = a.foo; | ||
· ─┬─ | ||
· ╰── unknown field foo | ||
5 │ } | ||
╰──── | ||
|
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,9 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
struct Foo { | ||
bar: i32, | ||
} | ||
|
||
fn main(foo: Foo) { | ||
let bar = foo.baz; | ||
} |
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,11 @@ | ||
Error: sema::invalid_struct_field_reference | ||
|
||
× invalid field reference to baz in type Foo | ||
╭─[invalid-struct-field-reference.eight:8:17] | ||
7 │ fn main(foo: Foo) { | ||
8 │ let bar = foo.baz; | ||
· ─┬─ | ||
· ╰── unknown field baz | ||
9 │ } | ||
╰──── | ||
|
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,9 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
struct Foo { | ||
bar: i32, | ||
} | ||
|
||
fn main() { | ||
let foo = new Foo {}; | ||
} |
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,17 @@ | ||
Error: sema::missing_field | ||
|
||
× the field bar is missing in construction of Foo | ||
╭─[missing-field.eight:4:3] | ||
3 │ struct Foo { | ||
4 │ bar: i32, | ||
· ────┬──── | ||
· ╰── field bar defined here | ||
5 │ } | ||
6 │ | ||
7 │ fn main() { | ||
8 │ let foo = new Foo {}; | ||
· ─────┬──── | ||
· ╰── construction does not name field bar | ||
9 │ } | ||
╰──── | ||
|
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,6 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
fn main() { | ||
// Trait Add does not exist here | ||
let a = 1 + 2; | ||
} |
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,11 @@ | ||
Error: sema::trait_does_not_exist | ||
|
||
× trait Add does not exist | ||
╭─[trait-does-not-exist.eight:5:13] | ||
4 │ // Trait Add does not exist here | ||
5 │ let a = 1 + 2; | ||
· ┬ | ||
· ╰── required trait Add to exist | ||
6 │ } | ||
╰──── | ||
|
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,11 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
trait Add<A, B, R> { | ||
fn add(a: A, b: B) -> R; | ||
} | ||
|
||
instance Add<i32, i32, i32> {} | ||
|
||
fn main() { | ||
let a = 1 + 2; | ||
} |
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,11 @@ | ||
Error: sema::trait_instance_missing_fn | ||
|
||
× trait instance Add does not derive method add | ||
╭─[trait-instance-missing-fn.eight:10:13] | ||
9 │ fn main() { | ||
10 │ let a = 1 + 2; | ||
· ┬ | ||
· ╰── trait instance Add does not derive method add | ||
11 │ } | ||
╰──── | ||
|
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,12 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
trait Add<A, B, R> { | ||
} | ||
|
||
instance Add<i32, i32, i32> { | ||
intrinsic_fn add(a: i32, b: i32) -> i32; | ||
} | ||
|
||
fn main() { | ||
let a = 1 + 2; | ||
} |
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,11 @@ | ||
Error: sema::trait_method_does_not_exist | ||
|
||
× trait Add does not have method add | ||
╭─[trait-method-does-not-exist.eight:11:13] | ||
10 │ fn main() { | ||
11 │ let a = 1 + 2; | ||
· ┬ | ||
· ╰── required method add for trait Add | ||
12 │ } | ||
╰──── | ||
|
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 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
intrinsic_fn get_i32() -> i32; | ||
|
||
fn main() { | ||
let dummy: bool = get_i32(); | ||
} |
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,12 @@ | ||
Error: sema::type_mismatch | ||
|
||
× type mismatch | ||
╭─[type-mismatch.eight:6:21] | ||
5 │ fn main() { | ||
6 │ let dummy: bool = get_i32(); | ||
· ───┬────┬ | ||
· │ ╰── expected type bool | ||
· ╰── the expression has type i32 | ||
7 │ } | ||
╰──── | ||
|
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,9 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
struct Foo { | ||
bar: i32, | ||
} | ||
|
||
fn main() { | ||
let foo = new Foo { giggles: 123 }; | ||
} |
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,11 @@ | ||
Error: sema::unknown_field | ||
|
||
× the type Foo does not have a field named giggles | ||
╭─[unknown-field.eight:8:23] | ||
7 │ fn main() { | ||
8 │ let foo = new Foo { giggles: 123 }; | ||
· ───┬─── | ||
· ╰── this field does not exist | ||
9 │ } | ||
╰──── | ||
|
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,3 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
intrinsic_type i69; |
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,10 @@ | ||
Error: sema::unknown_intrinsic_type_type | ||
|
||
× unknown intrinsic type i69 | ||
╭─[unknown-intrinsic-type.eight:3:16] | ||
2 │ | ||
3 │ intrinsic_type i69; | ||
· ─┬─ | ||
· ╰── could not find type i69 | ||
╰──── | ||
|
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 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
fn foo<T>(a: T, b: T) -> T {} | ||
|
||
fn main() { | ||
let foo = foo::<i32, bool>(1, 2); | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/ui/hir/wrong-function-type-argument-count.eight.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,12 @@ | ||
Error: sema::wrong_function_type_argument_count | ||
|
||
× function foo requires 1 type arguments, but 2 were supplied | ||
╭─[wrong-function-type-argument-count.eight:6:13] | ||
5 │ fn main() { | ||
6 │ let foo = foo::<i32, bool>(1, 2); | ||
· ───────────┬──────────┬ | ||
· │ ╰── declares 1 type arguments | ||
· ╰── supplied 2 type arguments | ||
7 │ } | ||
╰──── | ||
|
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,9 @@ | ||
// RUN: not %eightc %s 2>&1 | %regtest test %s | ||
|
||
trait Add<A, B, R> { | ||
fn add(a: A, b: B) -> R; | ||
} | ||
|
||
instance Add<i32, i32> { | ||
intrinsic_fn add(a: i32, b: i32) -> i32; | ||
} |
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,17 @@ | ||
Error: sema::wrong_trait_type_argument_count | ||
|
||
× trait Add requires 3 type arguments, but 2 were supplied | ||
╭─[wrong-trait-type-argument-count.eight:3:7] | ||
2 │ | ||
3 │ trait Add<A, B, R> { | ||
· ─┬─ | ||
· ╰── declares 3 type arguments | ||
4 │ fn add(a: A, b: B) -> R; | ||
5 │ } | ||
6 │ | ||
7 │ instance Add<i32, i32> { | ||
· ─┬─ | ||
· ╰── supplied 2 type arguments | ||
8 │ intrinsic_fn add(a: i32, b: i32) -> i32; | ||
╰──── | ||
|