Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(brillig): master into brillig main #1663

Merged
merged 9 commits into from
Jun 13, 2023
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ edition = "2021"
rust-version = "1.66"

[workspace.dependencies]
acvm = "=0.14.3"
acvm = "=0.14.4"
arena = { path = "crates/arena" }
fm = { path = "crates/fm" }
iter-extended = { path = "crates/iter-extended" }
Expand All @@ -40,8 +40,8 @@ noir_wasm = { path = "crates/wasm" }

cfg-if = "1.0.0"
clap = { version = "4.1.4", features = ["derive"] }
codespan = "0.9.5"
codespan-reporting = "0.9.5"
codespan = "0.11.1"
codespan-reporting = "0.11.1"
chumsky = { git = "https://github.com/jfecher/chumsky", rev = "ad9d312" }
dirs = "4"
serde = { version = "1.0.136", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/fm/src/file_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl FileMap {
FileId(file_id)
}
pub fn get_file(&self, file_id: FileId) -> Option<File> {
self.0.get(file_id.0).map(File)
self.0.get(file_id.0).map(File).ok()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main(x: Field) {
assert(x == 1);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "0x00"
y = "0x10"
18 changes: 18 additions & 0 deletions crates/nargo_cli/tests/test_data_ssa_refactor/bit_and/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// You can only do bit operations with integers.
// (Kobi/Daira/Circom/#37) https://github.com/iden3/circom/issues/37
fn main(x : Field, y : Field) {
let x_as_u8 = x as u8;
let y_as_u8 = y as u8;

assert((x_as_u8 & y_as_u8) == x_as_u8);

//bitwise and with 1 bit:
let flag = (x == 0) & (y == 16);
assert(flag);

//bitwise and with odd bits:
let x_as_u11 = x as u11;
let y_as_u11 = y as u11;
assert((x_as_u11 & y_as_u11) == x_as_u11);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = 64
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn main(x: u64) {
let two: u64 = 2;
let three: u64 = 3;

// comptime shifts on comptime values
assert(two << 2 == 8);
assert((two << 3) / 8 == two);
assert((three >> 1) == 1);

// comptime shifts on runtime values
assert(x << 1 == 128);
assert(x >> 2 == 16);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use dep::std;
fn main(x: u1) {
assert(!x == 0);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "1"
y = "0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use dep::std;
fn main(x: u1, y: u1) {
assert(x | y == 1);

assert(x | y | x == 1);
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ fn main(x: Field) {
}

#[oracle(oracle_print_impl)]
unconstrained fn oracle_print(_x : Field) {}
unconstrained fn oracle_print(_x : Field) -> Field {}
kevaundray marked this conversation as resolved.
Show resolved Hide resolved

unconstrained fn oracle_print_wrapper(x: Field) {
oracle_print(x);
}

#[oracle(oracle_print_array_impl)]
unconstrained fn oracle_print_array(_arr : [Field; 2]) {}
unconstrained fn oracle_print_array(_arr : [Field; 2]) -> Field {}

unconstrained fn oracle_print_array_wrapper(arr: [Field; 2]) {
oracle_print_array(arr);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "10"
y = "10"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main(x: Field, y: Field) {
let z = x == y;
let t = z as u8;
assert(t == 1);
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a = [1, 2, 3]
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
fn main(a: [Field; 3]) {
let i = 1;

// Using a comptime variable as a parameter should not make it non-comptime
let ii = foo(i);
let elem1 = a[i];

// Nor should using it in an expression with a non-comptime variable.
let two = i + ii;
assert(i == ii);

let elem2 = a[i];
assert(elem1 == elem2);
assert(two == 2);
}

fn foo(x: Field) -> Field { x }
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 5
y = 6
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main(x: Field, y: Field) {
let flag = (x == 1) | (y == 2);
assert(flag | false == flag);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 3
y = 2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main(x : Field, y : pub Field) {
assert(x * 2 == y * 3);
}

contract Foo {
fn double(x: Field) -> pub Field { x * 2 }
fn triple(x: Field) -> pub Field { x * 3 }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
input = "1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
use dep::std;

fn main(input : Field) -> pub Field {
std::hash::hash_to_field([input])
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = true
y = [true, false]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main(x : bool, y: [bool;2]) {
if x {
assert(1 != 2);
}

assert(x);
assert(y[0] != y[1]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x = "8"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main(x: pub Field) -> pub Field {
x
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "2"
y = "13"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn hello(x : Field) -> Field {
x
}
14 changes: 14 additions & 0 deletions crates/nargo_cli/tests/test_data_ssa_refactor/modules/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mod foo;
// This is a comment.
//
// `main` is the entry point to a binary
//
// You can have a `Binary` or a `Library`
// Release : 0.2
//
// To run a proof on the command line, type `cargo run prove {proof_name}`
//
// To verify that proof, type `cargo run verify {proof_name}`
fn main(x: Field, y: pub Field) {
assert(x != foo::hello(y));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
authors = [""]
compiler_version = "0.1"

[dependencies]
Loading