Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions compiler/noirc_frontend/src/ast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,11 @@
use acvm::acir::AcirField;
use iter_extended::vecmap;

use strum::IntoEnumIterator;
use strum_macros::EnumIter;

#[cfg_attr(test, derive(Arbitrary))]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Ord, PartialOrd)]
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Ord, PartialOrd, EnumIter)]
pub enum IntegerBitSize {
One,
Eight,
Expand All @@ -69,7 +72,7 @@

impl IntegerBitSize {
pub fn allowed_sizes() -> Vec<Self> {
vec![Self::One, Self::Eight, Self::ThirtyTwo, Self::SixtyFour]
IntegerBitSize::iter().collect()
}
}

Expand Down Expand Up @@ -605,7 +608,7 @@
Self::Public => write!(f, "pub"),
Self::Private => write!(f, "priv"),
Self::CallData(id) => write!(f, "calldata{id}"),
Self::ReturnData => write!(f, "returndata"),

Check warning on line 611 in compiler/noirc_frontend/src/ast/mod.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (returndata)
}
}
}
12 changes: 12 additions & 0 deletions compiler/noirc_frontend/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@

let chars = line.chars().collect::<Vec<_>>();
let first_caret = chars.iter().position(|c| *c == char).unwrap();
let last_caret = chars.iter().rposition(|c| *c == char).unwrap();

Check warning on line 296 in compiler/noirc_frontend/src/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (rposition)
let start = byte - last_line_length;
let span = Span::from((start + first_caret - 1) as u32..(start + last_caret) as u32);
let error = line.trim().trim_start_matches(char).trim().to_string();
Expand Down Expand Up @@ -3020,7 +3020,7 @@
// wouldn't panic due to infinite recursion, but the errors asserted here
// come from the compilation checks, which does static analysis to catch the
// problem before it even has a chance to cause a panic.
let srcs = vec![

Check warning on line 3023 in compiler/noirc_frontend/src/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (srcs)
r#"
fn main() {
^^^^ function `main` cannot return without recursing
Expand Down Expand Up @@ -3102,14 +3102,14 @@
"#,
];

for src in srcs {

Check warning on line 3105 in compiler/noirc_frontend/src/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (srcs)
check_errors(src);
}
}

#[test]
fn unconditional_recursion_pass() {
let srcs = vec![

Check warning on line 3112 in compiler/noirc_frontend/src/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (srcs)
r#"
fn main() {
if false { main(); }
Expand Down Expand Up @@ -3151,7 +3151,7 @@
"#,
];

for src in srcs {

Check warning on line 3154 in compiler/noirc_frontend/src/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (srcs)
assert_no_errors(src);
}
}
Expand Down Expand Up @@ -4137,12 +4137,24 @@
let mut array = [1, 2, 3];
borrow(&array);
^^^^^^ This requires the unstable feature 'ownership' which is not enabled
~~~~~~ Pass -Zownership to nargo to enable this feature at your own risk.

Check warning on line 4140 in compiler/noirc_frontend/src/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zownership)
}

fn borrow(_array: &[Field; 3]) {}
^^^^^^^^^^^ This requires the unstable feature 'ownership' which is not enabled
~~~~~~~~~~~ Pass -Zownership to nargo to enable this feature at your own risk.

Check warning on line 4145 in compiler/noirc_frontend/src/tests.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Zownership)
"#;
check_errors(src);
}

#[test]
fn errors_on_invalid_integer_bit_size() {
let src = r#"
fn main() {
let _: u42 = 4;
^^^ Use of invalid bit size 42
~~~ Allowed bit sizes for integers are 1, 8, 16, 32, 64, 128
}
"#;
check_errors(src);
}
Loading