Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,16 +515,22 @@ impl DefCollector {
) {
let unused_imports = context.usage_tracker.unused_items().iter();
let unused_imports = unused_imports.filter(|(module_id, _)| module_id.krate == crate_id);

errors.extend(unused_imports.flat_map(|(_, usage_tracker)| {
usage_tracker.iter().map(|(ident, unused_item)| {
let ident = ident.clone();
CompilationError::ResolverError(ResolverError::UnusedItem {
ident,
item: *unused_item,
let mut unused_errors = unused_imports
.flat_map(|(_, unused_items)| {
unused_items.iter().map(|(ident, unused_item)| {
let ident = ident.clone();
CompilationError::ResolverError(ResolverError::UnusedItem {
ident,
item: *unused_item,
})
})
})
}));
.collect::<Vec<_>>();

// Make sure errors always show up in the same order when compiling the same codebase
unused_errors.sort_by_key(|error| error.location());

errors.extend(unused_errors);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: Could not determine array length `-1`, encountered error: `The value `-1` cannot fit into `numeric u32` which has a maximum size of `4294967295``
┌─ src/main.nr:13:5
13 │ push_zero(pop(array))
│ ---------

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: Could not determine array length `-1`, encountered error: `The value `-1` cannot fit into `numeric u32` which has a maximum size of `4294967295``
┌─ src/main.nr:12:5
12 │ pop([]);
│ ---

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: Type provided when a numeric generic was expected
┌─ src/main.nr:6:18
6 │ fn foo<N>(array: [Field; N]) {
│ ---------- the numeric generic is not of type `u32`

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: Argument is not constant
┌─ src/main.nr:4:5
4 │ assert_constant([dynamic_one]);
│ ------------------------------
= Call stack:
1. src/main.nr:4:5

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: Argument is not constant
┌─ src/main.nr:4:5
4 │ assert_constant(dynamic_one + 1 == 3);
│ -------------------------------------
= Call stack:
1. src/main.nr:4:5

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: Argument is not constant
┌─ src/main.nr:4:5
4 │ assert_constant(&[dynamic_one]);
│ -------------------------------
= Call stack:
1. src/main.nr:4:5

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: Argument is not constant
┌─ src/main.nr:11:5
11 │ assert_constant(foo_dynamic_array);
│ ----------------------------------
= Call stack:
1. src/main.nr:11:5

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: Argument is not constant
┌─ src/main.nr:11:5
11 │ assert_constant(foo_dynamic);
│ ----------------------------
= Call stack:
1. src/main.nr:11:5

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: Argument is not constant
┌─ src/main.nr:11:5
11 │ assert_constant(foo_dynamic_slice);
│ ----------------------------------
= Call stack:
1. src/main.nr:11:5

Aborting due to 1 previous error
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: Argument is not constant
┌─ src/main.nr:4:5
4 │ assert_constant((dynamic_one, 2));
│ ---------------------------------
= Call stack:
1. src/main.nr:4:5

Aborting due to 1 previous error
11 changes: 11 additions & 0 deletions test_programs/compile_failure/assert_constant_fail/stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: Argument is not constant
┌─ src/main.nr:9:5
9 │ assert_constant(non_constant);
│ -----------------------------
= Call stack:
1. src/main.nr:4:5
2. src/main.nr:9:5

Aborting due to 1 previous error
10 changes: 10 additions & 0 deletions test_programs/compile_failure/assert_constant_false/stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error:
┌─ src/main.nr:2:5
2 │ std::static_assert(false, "");
│ -----------------------------
= Call stack:
1. src/main.nr:2:5

Aborting due to 1 previous error
8 changes: 8 additions & 0 deletions test_programs/compile_failure/assert_eq_struct/stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: No matching impl found for `myStruct: Eq`
┌─ src/main.nr:4:15
4 │ assert_eq(x, y);
│ ---- No impl for `myStruct: Eq`

Aborting due to 1 previous error
15 changes: 15 additions & 0 deletions test_programs/compile_failure/brillig_mut_ref_from_acir/stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
warning: unused variable y
┌─ src/main.nr:5:23
5 │ fn main(mut x: Field, y: pub Field) {
│ - unused variable

error: Cannot pass a mutable reference from a constrained runtime to an unconstrained runtime
┌─ src/main.nr:7:48
7 │ let returned_x = unsafe { mut_ref_identity(&mut x) };
│ ------

Aborting due to 1 previous error
151 changes: 151 additions & 0 deletions test_programs/compile_failure/brillig_nested_slices/stderr.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
warning: unused variable value
┌─ src/main.nr:12:40
12 │ unconstrained fn create_foo(id: Field, value: Field) -> NestedSliceStruct {
│ ----- unused variable

error: No method named 'push_back' found for type '[Field; 1]'
┌─ src/main.nr:14:11
14 │ arr = arr.push_back(value);
│ --------------------

error: Cannot assign an expression of type [NestedSliceStruct] to a value of type [NestedSliceStruct; 2]
┌─ src/main.nr:27:13
27 │ slice = push_back_to_slice(slice, create_foo(0, 42));
│ --------------------------------------------

error: No method named 'push_front' found for type '[NestedSliceStruct; 2]'
┌─ src/main.nr:39:13
39 │ slice = slice.push_front(create_foo(1, 43));
│ -----------------------------------

error: No method named 'push_back' found for type '[NestedSliceStruct; 2]'
┌─ src/main.nr:40:13
40 │ slice = slice.push_back(create_foo(2, 44));
│ ----------------------------------

error: No method named 'pop_front' found for type '[NestedSliceStruct; 2]'
┌─ src/main.nr:44:28
44 │ let pop_front_result = slice.pop_front();
│ -----------------

error: Object type is unknown in field access
┌─ src/main.nr:45:30
45 │ slice = pop_front_result.1;
│ - Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: Object type is unknown in field access
┌─ src/main.nr:46:29
46 │ assert(pop_front_result.0.id == 1);
│ - Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: No method named 'pop_back' found for type '[NestedSliceStruct; 2]'
┌─ src/main.nr:48:27
48 │ let pop_back_result = slice.pop_back();
│ ----------------

error: Object type is unknown in field access
┌─ src/main.nr:49:29
49 │ slice = pop_back_result.0;
│ - Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: Object type is unknown in field access
┌─ src/main.nr:50:28
50 │ assert(pop_back_result.1.id == 2);
│ - Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: No method named 'remove' found for type '[NestedSliceStruct; 2]'
┌─ src/main.nr:54:29
54 │ let mut remove_result = slice.remove(0);
│ ---------------

error: Object type is unknown in field access
┌─ src/main.nr:55:27
55 │ slice = remove_result.0;
│ - Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: Object type is unknown in field access
┌─ src/main.nr:56:42
56 │ let mut removed_item = remove_result.1;
│ - Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: Object type is unknown in field access
┌─ src/main.nr:57:25
57 │ assert(removed_item.arr[0] == a);
│ --- Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: No method named 'remove' found for type '[NestedSliceStruct; 2]'
┌─ src/main.nr:59:21
59 │ remove_result = slice.remove(1);
│ ---------------

error: Object type is unknown in field access
┌─ src/main.nr:60:27
60 │ slice = remove_result.0;
│ - Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: Object type is unknown in field access
┌─ src/main.nr:61:34
61 │ removed_item = remove_result.1;
│ - Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: Object type is unknown in field access
┌─ src/main.nr:62:25
62 │ assert(removed_item.arr[0] == 0);
│ --- Type must be known by this point
= Try adding a type annotation for the object type before this expression

error: No method named 'insert' found for type '[NestedSliceStruct; 2]'
┌─ src/main.nr:67:13
67 │ slice = slice.insert(1, removed_item);
│ -----------------------------

Aborting due to 19 previous errors
Loading