Skip to content

Commit 93d83bf

Browse files
authored
feat: add support for reading boolean arrays from toml (#900)
1 parent f729a00 commit 93d83bf

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
x = true
2+
y = [true, false]
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
fn main(x : bool) {
1+
fn main(x : bool, y: [bool;2]) {
22
if x {
33
constrain 1 != 2;
44
}
5+
56
constrain x;
7+
constrain y[0] != y[1];
68
}

crates/noirc_abi/src/input_parser/toml.rs

+14
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ enum TomlTypes {
6060
ArrayNum(Vec<u64>),
6161
// Array of hexadecimal integers
6262
ArrayString(Vec<String>),
63+
// Array of booleans
64+
ArrayBool(Vec<bool>),
6365
// Struct of TomlTypes
6466
Table(BTreeMap<String, TomlTypes>),
6567
}
@@ -122,6 +124,18 @@ impl InputValue {
122124

123125
InputValue::Vec(array_elements)
124126
}
127+
TomlTypes::ArrayBool(arr_bool) => {
128+
let array_elements = vecmap(arr_bool, |elem_bool| {
129+
if elem_bool {
130+
FieldElement::one()
131+
} else {
132+
FieldElement::zero()
133+
}
134+
});
135+
136+
InputValue::Vec(array_elements)
137+
}
138+
125139
TomlTypes::Table(table) => {
126140
let fields = match param_type {
127141
AbiType::Struct { fields } => fields,

0 commit comments

Comments
 (0)