Skip to content

Commit

Permalink
Merge branch 'master' into backend-errors
Browse files Browse the repository at this point in the history
* master:
  chore: remove usage of `serial_test` dependency (#2598)
  fix: Implement auto-dereferencing when calling methods (#2581)
  chore(noir): Release 0.11.1 (#2594)
  • Loading branch information
TomAFrench committed Sep 7, 2023
2 parents 54cc07b + ed7ad6e commit 8a6b501
Show file tree
Hide file tree
Showing 17 changed files with 73 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.11.0"
".": "0.11.1"
}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## [0.11.1](https://github.com/noir-lang/noir/compare/v0.11.0...v0.11.1) (2023-09-07)


### Features

* Enable dynamic indices on slices ([#2446](https://github.com/noir-lang/noir/issues/2446)) ([c5c4052](https://github.com/noir-lang/noir/commit/c5c40529d8c000ba61f3372b336e57947673646a))


### Bug Fixes

* Disable loop unrolling in brillig ([#2590](https://github.com/noir-lang/noir/issues/2590)) ([464f878](https://github.com/noir-lang/noir/commit/464f87834ada04320ea396cb4bdbab3317e036db))

## [0.11.0](https://github.com/noir-lang/noir/compare/v0.10.5...v0.11.0) (2023-09-07)


Expand Down
68 changes: 15 additions & 53 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ resolver = "2"

[workspace.package]
# x-release-please-start-version
version = "0.11.0"
version = "0.11.1"
# x-release-please-end
authors = ["The Noir Team <[email protected]>"]
edition = "2021"
Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ reqwest = { version = "0.11.16", default-features = false, features = [
] }

[dev-dependencies]
serial_test = "2.0.0"
test-binary = "3.0.1"

[build-dependencies]
Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/cli/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ impl ContractCommand {
}

#[test]
#[serial_test::serial]
fn contract_command() -> Result<(), BackendError> {
use tempfile::tempdir;

Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/cli/gates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ impl GatesCommand {
}

#[test]
#[serial_test::serial]
fn gate_command() -> Result<(), BackendError> {
use tempfile::tempdir;

Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/cli/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ impl InfoCommand {
}

#[test]
#[serial_test::serial]
fn info_command() -> Result<(), BackendError> {
use acvm::acir::circuit::black_box_functions::BlackBoxFunc;
use acvm::acir::circuit::opcodes::{BlackBoxFuncCall, Opcode};
Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ pub(crate) use verify::VerifyCommand;
pub(crate) use write_vk::WriteVkCommand;

#[test]
#[serial_test::serial]
fn no_command_provided_works() -> Result<(), crate::BackendError> {
// This is a simple test to check that the binaries work

Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/cli/prove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ impl ProveCommand {
}

#[test]
#[serial_test::serial]
fn prove_command() -> Result<(), BackendError> {
use tempfile::tempdir;

Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/cli/verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ impl VerifyCommand {
}

#[test]
#[serial_test::serial]
fn verify_command() -> Result<(), BackendError> {
use tempfile::tempdir;

Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/cli/write_vk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ impl WriteVkCommand {
}

#[test]
#[serial_test::serial]
fn write_vk_command() -> Result<(), BackendError> {
use tempfile::tempdir;

Expand Down
1 change: 0 additions & 1 deletion crates/acvm_backend_barretenberg/src/smart_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ mod tests {
use crate::{get_mock_backend, BackendError};

#[test]
#[serial_test::serial]
fn test_smart_contract() -> Result<(), BackendError> {
let expression = &(Witness(1) + Witness(2)) - &Expression::from(Witness(3));
let constraint = Opcode::Arithmetic(expression);
Expand Down
13 changes: 13 additions & 0 deletions crates/nargo_cli/tests/execution_success/references/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ fn main(mut x: Field) {
regression_2218_if_inner_else(20, x);
regression_2218_else(x, 3);
regression_2218_loop(x, 10);

regression_2560(s_ref);
}

fn add1(x: &mut Field) {
Expand All @@ -64,6 +66,10 @@ impl S {
fn add2(&mut self) {
self.y += 2;
}

fn get_y(self) -> Field {
self.y
}
}

fn mutate_copy(mut a: Field) {
Expand Down Expand Up @@ -230,3 +236,10 @@ fn regression_2218_loop(x: Field, y: Field) {
}
assert(*q1 == 2);
}

// This is more a feature test than a proper regression.
// Before, we never automatically dereferenced objects in method calls to their value types.
// Now, we insert as many `*` as necessary to get to `S`.
fn regression_2560(s_ref: &mut S) {
assert(s_ref.get_y() == 7);
}
31 changes: 29 additions & 2 deletions crates/noirc_frontend/src/hir/type_check/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ impl<'interner> TypeChecker<'interner> {
};

if let Some(expected_object_type) = expected_object_type {
if matches!(expected_object_type.follow_bindings(), Type::MutableReference(_)) {
let actual_type = argument_types[0].0.follow_bindings();
let actual_type = argument_types[0].0.follow_bindings();

if matches!(expected_object_type.follow_bindings(), Type::MutableReference(_)) {
if !matches!(actual_type, Type::MutableReference(_)) {
if let Err(error) = verify_mutable_reference(self.interner, method_call.object)
{
Expand Down Expand Up @@ -350,10 +350,37 @@ impl<'interner> TypeChecker<'interner> {
);
}
}
// Otherwise if the object type is a mutable reference and the method is not, insert as
// many dereferences as needed.
} else if matches!(actual_type, Type::MutableReference(_)) {
let (object, new_type) =
self.insert_auto_dereferences(method_call.object, actual_type);
method_call.object = object;
argument_types[0].0 = new_type;
}
}
}

/// Insert as many dereference operations as necessary to automatically dereference a method
/// call object to its base value type T.
fn insert_auto_dereferences(&mut self, object: ExprId, typ: Type) -> (ExprId, Type) {
if let Type::MutableReference(element) = typ {
let location = self.interner.id_location(object);

let object = self.interner.push_expr(HirExpression::Prefix(HirPrefixExpression {
operator: UnaryOp::Dereference { implicitly_added: true },
rhs: object,
}));
self.interner.push_expr_type(&object, element.as_ref().clone());
self.interner.push_expr_location(object, location.span, location.file);

// Recursively dereference to allow for converting &mut &mut T to T
self.insert_auto_dereferences(object, *element)
} else {
(object, typ)
}
}

/// Given a method object: `(*foo).bar` of a method call `(*foo).bar.baz()`, remove the
/// implicitly added dereference operator if one is found.
///
Expand Down
2 changes: 1 addition & 1 deletion crates/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"collaborators": [
"The Noir Team <[email protected]>"
],
"version": "0.11.0",
"version": "0.11.1",
"license": "(MIT OR Apache-2.0)",
"main": "./nodejs/noir_wasm.js",
"types": "./web/noir_wasm.d.ts",
Expand Down
Loading

0 comments on commit 8a6b501

Please sign in to comment.