From e3287668b772959c24ae05a6f006dbc10ccfd9bc Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Wed, 12 Jun 2024 11:57:24 +0100 Subject: [PATCH 1/6] chore: push code related to ABI gen into `noirc_driver` (#5218) # Description ## Problem\* Resolves ## Summary\* I'm not sure why this code was placed here. This code is only relevant for ABI gen so I've pushed it into the`abi_gen` module. This simplifies the dependency graph. ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [X] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --------- Co-authored-by: jfecher --- Cargo.lock | 1 - compiler/noirc_driver/src/abi_gen.rs | 106 +++++++++++++++++++++++++-- compiler/noirc_driver/src/lib.rs | 4 +- tooling/noirc_abi/Cargo.toml | 11 +-- tooling/noirc_abi/src/lib.rs | 102 -------------------------- 5 files changed, 102 insertions(+), 122 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd575d0dca2..a8eab53dc07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2727,7 +2727,6 @@ version = "0.30.0" dependencies = [ "acvm", "iter-extended", - "noirc_frontend", "noirc_printable_type", "num-bigint", "num-traits", diff --git a/compiler/noirc_driver/src/abi_gen.rs b/compiler/noirc_driver/src/abi_gen.rs index 71dd1b18761..e2c7fea3c07 100644 --- a/compiler/noirc_driver/src/abi_gen.rs +++ b/compiler/noirc_driver/src/abi_gen.rs @@ -2,14 +2,17 @@ use std::collections::BTreeMap; use acvm::acir::circuit::ErrorSelector; use iter_extended::vecmap; -use noirc_abi::{Abi, AbiErrorType, AbiParameter, AbiReturnType, AbiType, AbiValue}; -use noirc_frontend::ast::Visibility; +use noirc_abi::{ + Abi, AbiErrorType, AbiParameter, AbiReturnType, AbiType, AbiValue, AbiVisibility, Sign, +}; +use noirc_frontend::ast::{Signedness, Visibility}; use noirc_frontend::{ hir::Context, hir_def::{expr::HirArrayLiteral, function::Param, stmt::HirPattern, types::Type}, macros_api::{HirExpression, HirLiteral}, node_interner::{FuncId, NodeInterner}, }; +use noirc_frontend::{TypeBinding, TypeVariableKind}; /// Arranges a function signature and a generated circuit's return witnesses into a /// `noirc_abi::Abi`. @@ -20,15 +23,102 @@ pub(super) fn gen_abi( error_types: BTreeMap, ) -> Abi { let (parameters, return_type) = compute_function_abi(context, func_id); - let return_type = return_type - .map(|typ| AbiReturnType { abi_type: typ, visibility: return_visibility.into() }); + let return_type = return_type.map(|typ| AbiReturnType { + abi_type: typ, + visibility: to_abi_visibility(return_visibility), + }); let error_types = error_types .into_iter() - .map(|(selector, typ)| (selector, AbiErrorType::from_type(context, &typ))) + .map(|(selector, typ)| (selector, build_abi_error_type(context, &typ))) .collect(); Abi { parameters, return_type, error_types } } +fn build_abi_error_type(context: &Context, typ: &Type) -> AbiErrorType { + match typ { + Type::FmtString(len, item_types) => { + let length = len.evaluate_to_u32().expect("Cannot evaluate fmt length"); + let Type::Tuple(item_types) = item_types.as_ref() else { + unreachable!("FmtString items must be a tuple") + }; + let item_types = + item_types.iter().map(|typ| abi_type_from_hir_type(context, typ)).collect(); + AbiErrorType::FmtString { length, item_types } + } + _ => AbiErrorType::Custom(abi_type_from_hir_type(context, typ)), + } +} + +pub(super) fn abi_type_from_hir_type(context: &Context, typ: &Type) -> AbiType { + match typ { + Type::FieldElement => AbiType::Field, + Type::Array(size, typ) => { + let length = size + .evaluate_to_u32() + .expect("Cannot have variable sized arrays as a parameter to main"); + let typ = typ.as_ref(); + AbiType::Array { length, typ: Box::new(abi_type_from_hir_type(context, typ)) } + } + Type::Integer(sign, bit_width) => { + let sign = match sign { + Signedness::Unsigned => Sign::Unsigned, + Signedness::Signed => Sign::Signed, + }; + + AbiType::Integer { sign, width: (*bit_width).into() } + } + Type::TypeVariable(binding, TypeVariableKind::IntegerOrField) + | Type::TypeVariable(binding, TypeVariableKind::Integer) => match &*binding.borrow() { + TypeBinding::Bound(typ) => abi_type_from_hir_type(context, typ), + TypeBinding::Unbound(_) => { + abi_type_from_hir_type(context, &Type::default_int_or_field_type()) + } + }, + Type::Bool => AbiType::Boolean, + Type::String(size) => { + let size = size + .evaluate_to_u32() + .expect("Cannot have variable sized strings as a parameter to main"); + AbiType::String { length: size } + } + + Type::Struct(def, args) => { + let struct_type = def.borrow(); + let fields = struct_type.get_fields(args); + let fields = + vecmap(fields, |(name, typ)| (name, abi_type_from_hir_type(context, &typ))); + // For the ABI, we always want to resolve the struct paths from the root crate + let path = context.fully_qualified_struct_path(context.root_crate_id(), struct_type.id); + AbiType::Struct { fields, path } + } + Type::Alias(def, args) => abi_type_from_hir_type(context, &def.borrow().get_type(args)), + Type::Tuple(fields) => { + let fields = vecmap(fields, |typ| abi_type_from_hir_type(context, typ)); + AbiType::Tuple { fields } + } + Type::Error + | Type::Unit + | Type::Constant(_) + | Type::TraitAsType(..) + | Type::TypeVariable(_, _) + | Type::NamedGeneric(..) + | Type::Forall(..) + | Type::Code + | Type::Slice(_) + | Type::Function(_, _, _) => unreachable!("{typ} cannot be used in the abi"), + Type::FmtString(_, _) => unreachable!("format strings cannot be used in the abi"), + Type::MutableReference(_) => unreachable!("&mut cannot be used in the abi"), + } +} + +fn to_abi_visibility(value: Visibility) -> AbiVisibility { + match value { + Visibility::Public => AbiVisibility::Public, + Visibility::Private => AbiVisibility::Private, + Visibility::DataBus => AbiVisibility::DataBus, + } +} + pub(super) fn compute_function_abi( context: &Context, func_id: &FuncId, @@ -37,7 +127,7 @@ pub(super) fn compute_function_abi( let (parameters, return_type) = func_meta.function_signature(); let parameters = into_abi_params(context, parameters); - let return_type = return_type.map(|typ| AbiType::from_type(context, &typ)); + let return_type = return_type.map(|typ| abi_type_from_hir_type(context, &typ)); (parameters, return_type) } @@ -57,8 +147,8 @@ fn into_abi_params(context: &Context, params: Vec) -> Vec { let param_name = get_param_name(&pattern, &context.def_interner) .expect("Abi for tuple and struct parameters is unimplemented") .to_owned(); - let as_abi = AbiType::from_type(context, &typ); - AbiParameter { name: param_name, typ: as_abi, visibility: vis.into() } + let as_abi = abi_type_from_hir_type(context, &typ); + AbiParameter { name: param_name, typ: as_abi, visibility: to_abi_visibility(vis) } }) } diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index f8043a60f8c..2c8679eaa95 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -3,7 +3,7 @@ #![warn(unreachable_pub)] #![warn(clippy::semicolon_if_nothing_returned)] -use abi_gen::value_from_hir_expression; +use abi_gen::{abi_type_from_hir_type, value_from_hir_expression}; use acvm::acir::circuit::ExpressionWidth; use clap::Args; use fm::{FileId, FileManager}; @@ -468,7 +468,7 @@ fn compile_contract_inner( let typ = context.def_interner.get_struct(struct_id); let typ = typ.borrow(); let fields = vecmap(typ.get_fields(&[]), |(name, typ)| { - (name, AbiType::from_type(context, &typ)) + (name, abi_type_from_hir_type(context, &typ)) }); let path = context.fully_qualified_struct_path(context.root_crate_id(), typ.id); diff --git a/tooling/noirc_abi/Cargo.toml b/tooling/noirc_abi/Cargo.toml index baae2dfa35e..d450b268aee 100644 --- a/tooling/noirc_abi/Cargo.toml +++ b/tooling/noirc_abi/Cargo.toml @@ -11,7 +11,6 @@ license.workspace = true [dependencies] acvm.workspace = true iter-extended.workspace = true -noirc_frontend.workspace = true noirc_printable_type.workspace = true toml.workspace = true serde_json = "1.0" @@ -25,11 +24,5 @@ strum = "0.24" strum_macros = "0.24" [features] -bn254 = [ - "acvm/bn254", - "noirc_frontend/bn254", -] -bls12_381 = [ - "acvm/bls12_381", - "noirc_frontend/bls12_381", -] \ No newline at end of file +bn254 = ["acvm/bn254"] +bls12_381 = ["acvm/bls12_381"] diff --git a/tooling/noirc_abi/src/lib.rs b/tooling/noirc_abi/src/lib.rs index 514fac2e73d..2ebccbad1a0 100644 --- a/tooling/noirc_abi/src/lib.rs +++ b/tooling/noirc_abi/src/lib.rs @@ -13,8 +13,6 @@ use acvm::{ use errors::AbiError; use input_parser::InputValue; use iter_extended::{try_btree_map, try_vecmap, vecmap}; -use noirc_frontend::ast::{Signedness, Visibility}; -use noirc_frontend::{hir::Context, Type, TypeBinding, TypeVariableKind}; use noirc_printable_type::{ decode_value as printable_type_decode_value, PrintableType, PrintableValue, PrintableValueDisplay, @@ -87,26 +85,6 @@ pub enum AbiVisibility { DataBus, } -impl From for AbiVisibility { - fn from(value: Visibility) -> Self { - match value { - Visibility::Public => AbiVisibility::Public, - Visibility::Private => AbiVisibility::Private, - Visibility::DataBus => AbiVisibility::DataBus, - } - } -} - -impl From<&Visibility> for AbiVisibility { - fn from(value: &Visibility) -> Self { - match value { - Visibility::Public => AbiVisibility::Public, - Visibility::Private => AbiVisibility::Private, - Visibility::DataBus => AbiVisibility::DataBus, - } - } -} - #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum Sign { @@ -115,70 +93,6 @@ pub enum Sign { } impl AbiType { - pub fn from_type(context: &Context, typ: &Type) -> Self { - // Note; use strict_eq instead of partial_eq when comparing field types - // in this method, you most likely want to distinguish between public and private - match typ { - Type::FieldElement => Self::Field, - Type::Array(size, typ) => { - let length = size - .evaluate_to_u32() - .expect("Cannot have variable sized arrays as a parameter to main"); - let typ = typ.as_ref(); - Self::Array { length, typ: Box::new(Self::from_type(context, typ)) } - } - Type::Integer(sign, bit_width) => { - let sign = match sign { - Signedness::Unsigned => Sign::Unsigned, - Signedness::Signed => Sign::Signed, - }; - - Self::Integer { sign, width: (*bit_width).into() } - } - Type::TypeVariable(binding, TypeVariableKind::IntegerOrField) - | Type::TypeVariable(binding, TypeVariableKind::Integer) => match &*binding.borrow() { - TypeBinding::Bound(typ) => Self::from_type(context, typ), - TypeBinding::Unbound(_) => { - Self::from_type(context, &Type::default_int_or_field_type()) - } - }, - Type::Bool => Self::Boolean, - Type::String(size) => { - let size = size - .evaluate_to_u32() - .expect("Cannot have variable sized strings as a parameter to main"); - Self::String { length: size } - } - - Type::Struct(def, args) => { - let struct_type = def.borrow(); - let fields = struct_type.get_fields(args); - let fields = vecmap(fields, |(name, typ)| (name, Self::from_type(context, &typ))); - // For the ABI, we always want to resolve the struct paths from the root crate - let path = - context.fully_qualified_struct_path(context.root_crate_id(), struct_type.id); - Self::Struct { fields, path } - } - Type::Alias(def, args) => Self::from_type(context, &def.borrow().get_type(args)), - Type::Tuple(fields) => { - let fields = vecmap(fields, |typ| Self::from_type(context, typ)); - Self::Tuple { fields } - } - Type::Error - | Type::Unit - | Type::Constant(_) - | Type::TraitAsType(..) - | Type::TypeVariable(_, _) - | Type::NamedGeneric(..) - | Type::Forall(..) - | Type::Code - | Type::Slice(_) - | Type::Function(_, _, _) => unreachable!("{typ} cannot be used in the abi"), - Type::FmtString(_, _) => unreachable!("format strings cannot be used in the abi"), - Type::MutableReference(_) => unreachable!("&mut cannot be used in the abi"), - } - } - /// Returns the number of field elements required to represent the type once encoded. pub fn field_count(&self) -> u32 { match self { @@ -543,22 +457,6 @@ pub enum AbiErrorType { FmtString { length: u32, item_types: Vec }, Custom(AbiType), } -impl AbiErrorType { - pub fn from_type(context: &Context, typ: &Type) -> Self { - match typ { - Type::FmtString(len, item_types) => { - let length = len.evaluate_to_u32().expect("Cannot evaluate fmt length"); - let Type::Tuple(item_types) = item_types.as_ref() else { - unreachable!("FmtString items must be a tuple") - }; - let item_types = - item_types.iter().map(|typ| AbiType::from_type(context, typ)).collect(); - Self::FmtString { length, item_types } - } - _ => Self::Custom(AbiType::from_type(context, typ)), - } - } -} pub fn display_abi_error( fields: &[F], From 3e04cd5e122d83396f75818e78d45c65de178640 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro=20Sousa?= Date: Wed, 12 Jun 2024 12:25:38 +0100 Subject: [PATCH 2/6] chore: fixing all relative paths (#5220) Making the change as per the [docusaurus documentation](https://docusaurus.io/docs/advanced/routing#docs-routing) as this avoids mistakes when for some reason a link comes with a trailing slash, and other benefits --- docs/docs/noir/concepts/data_types/arrays.md | 4 +++- .../docs/noir/concepts/data_types/booleans.md | 4 ++-- docs/docs/noir/concepts/data_types/strings.md | 2 +- docs/docs/noir/concepts/generics.md | 4 ++-- docs/docs/noir/concepts/unconstrained.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 2 +- docs/docs/noir/standard_library/recursion.md | 2 +- docs/docs/tooling/debugger.md | 2 +- .../getting_started/01_hello_world.md | 4 ++-- .../getting_started/02_breakdown.md | 4 ++-- docs/versioned_docs/version-v0.17.0/index.md | 4 ++-- .../data_types/02_booleans.md | 4 ++-- .../data_types/03_strings.md | 2 +- .../language_concepts/data_types/04_arrays.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../version-v0.17.0/nargo/01_commands.md | 2 +- .../standard_library/black_box_fns.md | 20 ++++++++--------- .../standard_library/recursion.md | 2 +- .../getting_started/01_hello_world.md | 4 ++-- .../getting_started/02_breakdown.md | 4 ++-- docs/versioned_docs/version-v0.19.0/index.md | 4 ++-- .../data_types/02_booleans.md | 4 ++-- .../data_types/03_strings.md | 2 +- .../language_concepts/data_types/04_arrays.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../version-v0.19.0/nargo/01_commands.md | 2 +- .../standard_library/black_box_fns.md | 22 +++++++++---------- .../standard_library/recursion.md | 2 +- .../getting_started/01_hello_world.md | 4 ++-- .../getting_started/02_breakdown.md | 4 ++-- docs/versioned_docs/version-v0.19.1/index.md | 4 ++-- .../data_types/02_booleans.md | 4 ++-- .../data_types/03_strings.md | 2 +- .../language_concepts/data_types/04_arrays.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../version-v0.19.1/nargo/01_commands.md | 2 +- .../standard_library/black_box_fns.md | 22 +++++++++---------- .../standard_library/recursion.md | 2 +- .../getting_started/01_hello_world.md | 4 ++-- .../getting_started/02_breakdown.md | 4 ++-- docs/versioned_docs/version-v0.19.2/index.md | 4 ++-- .../data_types/02_booleans.md | 4 ++-- .../data_types/03_strings.md | 2 +- .../language_concepts/data_types/04_arrays.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../version-v0.19.2/nargo/01_commands.md | 2 +- .../standard_library/black_box_fns.md | 22 +++++++++---------- .../standard_library/recursion.md | 2 +- .../getting_started/01_hello_world.md | 4 ++-- .../getting_started/02_breakdown.md | 4 ++-- docs/versioned_docs/version-v0.19.3/index.md | 4 ++-- .../data_types/02_booleans.md | 4 ++-- .../data_types/03_strings.md | 2 +- .../language_concepts/data_types/04_arrays.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../version-v0.19.3/nargo/01_commands.md | 2 +- .../standard_library/black_box_fns.md | 22 +++++++++---------- .../standard_library/recursion.md | 2 +- .../getting_started/01_hello_world.md | 4 ++-- .../getting_started/02_breakdown.md | 4 ++-- docs/versioned_docs/version-v0.19.4/index.md | 4 ++-- .../data_types/02_booleans.md | 4 ++-- .../data_types/03_strings.md | 2 +- .../language_concepts/data_types/04_arrays.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../version-v0.19.4/nargo/01_commands.md | 2 +- .../standard_library/black_box_fns.md | 22 +++++++++---------- .../standard_library/recursion.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 22 +++++++++---------- .../noir/standard_library/recursion.md | 2 +- .../noir/syntax/data_types/arrays.md | 2 +- .../noir/syntax/data_types/booleans.md | 4 ++-- .../noir/syntax/data_types/strings.md | 2 +- .../noir/concepts/data_types/arrays.md | 4 +++- .../noir/concepts/data_types/booleans.md | 4 ++-- .../noir/concepts/data_types/strings.md | 2 +- .../version-v0.23.0/noir/concepts/generics.md | 4 ++-- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 20 ++++++++--------- .../noir/standard_library/recursion.md | 2 +- .../noir/concepts/data_types/arrays.md | 4 +++- .../noir/concepts/data_types/booleans.md | 4 ++-- .../noir/concepts/data_types/strings.md | 2 +- .../version-v0.24.0/noir/concepts/generics.md | 4 ++-- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 2 +- .../noir/standard_library/recursion.md | 2 +- .../noir/concepts/data_types/arrays.md | 4 +++- .../noir/concepts/data_types/booleans.md | 4 ++-- .../noir/concepts/data_types/strings.md | 2 +- .../version-v0.25.0/noir/concepts/generics.md | 4 ++-- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 2 +- .../noir/standard_library/recursion.md | 2 +- .../noir/concepts/data_types/arrays.md | 4 +++- .../noir/concepts/data_types/booleans.md | 4 ++-- .../noir/concepts/data_types/strings.md | 2 +- .../version-v0.26.0/noir/concepts/generics.md | 4 ++-- .../noir/concepts/unconstrained.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 2 +- .../noir/standard_library/recursion.md | 2 +- .../noir/concepts/data_types/arrays.md | 4 +++- .../noir/concepts/data_types/booleans.md | 4 ++-- .../noir/concepts/data_types/strings.md | 2 +- .../version-v0.27.0/noir/concepts/generics.md | 4 ++-- .../noir/concepts/unconstrained.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 2 +- .../noir/standard_library/recursion.md | 2 +- .../noir/concepts/data_types/arrays.md | 4 +++- .../noir/concepts/data_types/booleans.md | 4 ++-- .../noir/concepts/data_types/strings.md | 2 +- .../version-v0.28.0/noir/concepts/generics.md | 4 ++-- .../noir/concepts/unconstrained.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 2 +- .../noir/standard_library/recursion.md | 2 +- .../version-v0.28.0/tooling/debugger.md | 2 +- .../noir/concepts/data_types/arrays.md | 4 +++- .../noir/concepts/data_types/booleans.md | 4 ++-- .../noir/concepts/data_types/strings.md | 2 +- .../version-v0.29.0/noir/concepts/generics.md | 4 ++-- .../noir/concepts/unconstrained.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 2 +- .../noir/standard_library/recursion.md | 2 +- .../version-v0.29.0/tooling/debugger.md | 2 +- .../noir/concepts/data_types/arrays.md | 4 +++- .../noir/concepts/data_types/booleans.md | 4 ++-- .../noir/concepts/data_types/strings.md | 2 +- .../version-v0.30.0/noir/concepts/generics.md | 4 ++-- .../noir/concepts/unconstrained.md | 2 +- .../modules_packages_crates/dependencies.md | 4 ++-- .../noir/standard_library/black_box_fns.md | 2 +- .../noir/standard_library/recursion.md | 2 +- .../version-v0.30.0/tooling/debugger.md | 2 +- 139 files changed, 294 insertions(+), 276 deletions(-) diff --git a/docs/docs/noir/concepts/data_types/arrays.md b/docs/docs/noir/concepts/data_types/arrays.md index efce3e95d32..95d749053e2 100644 --- a/docs/docs/noir/concepts/data_types/arrays.md +++ b/docs/docs/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = &[]; ``` diff --git a/docs/docs/noir/concepts/data_types/booleans.md b/docs/docs/noir/concepts/data_types/booleans.md index 3dcfa836814..2507af710e7 100644 --- a/docs/docs/noir/concepts/data_types/booleans.md +++ b/docs/docs/noir/concepts/data_types/booleans.md @@ -24,5 +24,5 @@ fn main() { ``` The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/docs/noir/concepts/data_types/strings.md b/docs/docs/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/docs/noir/concepts/data_types/strings.md +++ b/docs/docs/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/docs/noir/concepts/generics.md b/docs/docs/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/docs/noir/concepts/generics.md +++ b/docs/docs/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/docs/noir/concepts/unconstrained.md b/docs/docs/noir/concepts/unconstrained.md index b8e71fe65f0..96f824c5e42 100644 --- a/docs/docs/noir/concepts/unconstrained.md +++ b/docs/docs/noir/concepts/unconstrained.md @@ -96,4 +96,4 @@ Generally we want to use brillig whenever there's something that's easy to verif ## Break and Continue -In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow/#break-and-continue) +In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow.md#break-and-continue) diff --git a/docs/docs/noir/modules_packages_crates/dependencies.md b/docs/docs/noir/modules_packages_crates/dependencies.md index 04c1703d929..2c028d85853 100644 --- a/docs/docs/noir/modules_packages_crates/dependencies.md +++ b/docs/docs/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/docs/noir/standard_library/black_box_fns.md b/docs/docs/noir/standard_library/black_box_fns.md index eeead580969..d5694250f05 100644 --- a/docs/docs/noir/standard_library/black_box_fns.md +++ b/docs/docs/noir/standard_library/black_box_fns.md @@ -25,7 +25,7 @@ Here is a list of the current black box functions: - XOR - RANGE - [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) -- [Recursive proof verification](./recursion) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/docs/noir/standard_library/recursion.md b/docs/docs/noir/standard_library/recursion.md index a93894043dc..f33c285cf4e 100644 --- a/docs/docs/noir/standard_library/recursion.md +++ b/docs/docs/noir/standard_library/recursion.md @@ -35,7 +35,7 @@ pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/docs/tooling/debugger.md b/docs/docs/tooling/debugger.md index 7c158d949d1..9b7565ba9ff 100644 --- a/docs/docs/tooling/debugger.md +++ b/docs/docs/tooling/debugger.md @@ -12,7 +12,7 @@ There are currently two ways of debugging Noir programs: 1. From VS Code, via the [vscode-noir](https://github.com/noir-lang/vscode-noir) extension. You can install it via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir). 2. Via the REPL debugger, which ships with Nargo. -In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/installation) and vscode-noir: +In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/installation/index.md) and vscode-noir: - Noir & Nargo ≥0.28.0 - Noir's VS Code extension ≥0.0.11 diff --git a/docs/versioned_docs/version-v0.17.0/getting_started/01_hello_world.md b/docs/versioned_docs/version-v0.17.0/getting_started/01_hello_world.md index d4daae605a2..34f8cd96fcd 100644 --- a/docs/versioned_docs/version-v0.17.0/getting_started/01_hello_world.md +++ b/docs/versioned_docs/version-v0.17.0/getting_started/01_hello_world.md @@ -74,7 +74,7 @@ x : Field, y : pub Field Program inputs in Noir are private by default (e.g. `x`), but can be labeled public using the keyword `pub` (e.g. `y`). To learn more about private and public values, check the -[Data Types](../language_concepts/data_types) section. +[Data Types](../language_concepts/data_types.md) section. The next line of the program specifies its body: @@ -84,7 +84,7 @@ assert(x != y); The Noir syntax `assert` can be interpreted as something similar to constraints in other zk-contract languages. -For more Noir syntax, check the [Language Concepts](../language_concepts/comments) chapter. +For more Noir syntax, check the [Language Concepts](../language_concepts/comments.md) chapter. ## Build In/Output Files diff --git a/docs/versioned_docs/version-v0.17.0/getting_started/02_breakdown.md b/docs/versioned_docs/version-v0.17.0/getting_started/02_breakdown.md index e7b1f33b339..8616feee917 100644 --- a/docs/versioned_docs/version-v0.17.0/getting_started/02_breakdown.md +++ b/docs/versioned_docs/version-v0.17.0/getting_started/02_breakdown.md @@ -51,7 +51,7 @@ license = "MIT" ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} ``` -Nargo.toml for a [workspace](../modules_packages_crates/workspaces) will look a bit different. For example: +Nargo.toml for a [workspace](../modules_packages_crates/workspaces.md) will look a bit different. For example: ```toml [workspace] @@ -74,7 +74,7 @@ The package section requires a number of fields including: #### Dependencies section -This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies) for more info. +This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies.md)for more info. `./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or verifier contract respectively. diff --git a/docs/versioned_docs/version-v0.17.0/index.md b/docs/versioned_docs/version-v0.17.0/index.md index 2d5e6f4454f..c88aabf0ac1 100644 --- a/docs/versioned_docs/version-v0.17.0/index.md +++ b/docs/versioned_docs/version-v0.17.0/index.md @@ -34,7 +34,7 @@ Noir can be used for a variety of purposes. ### Solidity Developers Noir currently includes a command to create a Solidity contract which verifies your Noir program. This will -be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier) command to create +be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands.md#nargo-codegen-verifier) command to create a verifier contract. ### Protocol Developers @@ -96,4 +96,4 @@ Some libraries that are available today include: - [Signed Int](https://github.com/resurgencelabs/signed_int) - a library for accessing a custom Signed Integer data type, allowing access to negative numbers on Noir - [Fraction](https://github.com/resurgencelabs/fraction) - a library for accessing fractional number data type in Noir, allowing results that aren't whole numbers -See the section on [dependencies](./modules_packages_crates/dependencies) for more information. +See the section on [dependencies](./modules_packages_crates/dependencies.md) for more information. diff --git a/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/02_booleans.md b/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/02_booleans.md index 885db167d83..d353606210a 100644 --- a/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/02_booleans.md +++ b/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/02_booleans.md @@ -26,5 +26,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/03_strings.md b/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/03_strings.md index c42f34ec3ad..4360893e9a2 100644 --- a/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/03_strings.md +++ b/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/03_strings.md @@ -16,7 +16,7 @@ keywords: The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`std::println()`. See more about [Logging](../../standard_library/logging). +`std::println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/04_arrays.md b/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/04_arrays.md index bdbd1798bef..1424ca2df14 100644 --- a/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/04_arrays.md +++ b/docs/versioned_docs/version-v0.17.0/language_concepts/data_types/04_arrays.md @@ -56,7 +56,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; diff --git a/docs/versioned_docs/version-v0.17.0/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.17.0/modules_packages_crates/dependencies.md index e91e73a4c4f..87a09293ea8 100644 --- a/docs/versioned_docs/version-v0.17.0/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.17.0/modules_packages_crates/dependencies.md @@ -81,14 +81,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.17.0/nargo/01_commands.md b/docs/versioned_docs/version-v0.17.0/nargo/01_commands.md index 65e2bdb44e3..e2b0af522f4 100644 --- a/docs/versioned_docs/version-v0.17.0/nargo/01_commands.md +++ b/docs/versioned_docs/version-v0.17.0/nargo/01_commands.md @@ -213,7 +213,7 @@ you run `nargo test`. To print `println` statements in tests, use the `--show-ou Takes an optional `--exact` flag which allows you to select tests based on an exact name. -See an example on the [testing page](./testing). +See an example on the [testing page](./testing.md). ### Options diff --git a/docs/versioned_docs/version-v0.17.0/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.17.0/standard_library/black_box_fns.md index a412de19d06..b4dedefe4c9 100644 --- a/docs/versioned_docs/version-v0.17.0/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.17.0/standard_library/black_box_fns.md @@ -26,19 +26,19 @@ fn sha256(_input : [u8; N]) -> [u8; 32] {} Here is a list of the current black box functions that are supported by UltraPlonk: - AES -- [SHA256](./cryptographic_primitives/hashes#sha256) -- [Schnorr signature verification](./cryptographic_primitives/schnorr) -- [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Pedersen](./cryptographic_primitives/hashes#pedersen) -- [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) -- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) -- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) -- [Compute merkle root](./merkle_trees#compute_merkle_root) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Pedersen](./cryptographic_primitives/hashes.mdx#pedersen) +- [HashToField128Security](./cryptographic_primitives/hashes.mdx#hash_to_field) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar.mdx) +- [Compute merkle root](./merkle_trees.md#compute_merkle_root) - AND - XOR - RANGE -- [Keccak256](./cryptographic_primitives/hashes#keccak256) -- [Recursive proof verification](./recursion) +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. To ensure compatibility across backends, the ACVM has fallback implementations of `AND`, `XOR` and `RANGE` defined in its standard library which it can seamlessly fallback to if the backend doesn't support them. diff --git a/docs/versioned_docs/version-v0.17.0/standard_library/recursion.md b/docs/versioned_docs/version-v0.17.0/standard_library/recursion.md index ff4c63acaa7..5e592a2fd89 100644 --- a/docs/versioned_docs/version-v0.17.0/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.17.0/standard_library/recursion.md @@ -15,7 +15,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.19.0/getting_started/01_hello_world.md b/docs/versioned_docs/version-v0.19.0/getting_started/01_hello_world.md index d4daae605a2..34f8cd96fcd 100644 --- a/docs/versioned_docs/version-v0.19.0/getting_started/01_hello_world.md +++ b/docs/versioned_docs/version-v0.19.0/getting_started/01_hello_world.md @@ -74,7 +74,7 @@ x : Field, y : pub Field Program inputs in Noir are private by default (e.g. `x`), but can be labeled public using the keyword `pub` (e.g. `y`). To learn more about private and public values, check the -[Data Types](../language_concepts/data_types) section. +[Data Types](../language_concepts/data_types.md) section. The next line of the program specifies its body: @@ -84,7 +84,7 @@ assert(x != y); The Noir syntax `assert` can be interpreted as something similar to constraints in other zk-contract languages. -For more Noir syntax, check the [Language Concepts](../language_concepts/comments) chapter. +For more Noir syntax, check the [Language Concepts](../language_concepts/comments.md) chapter. ## Build In/Output Files diff --git a/docs/versioned_docs/version-v0.19.0/getting_started/02_breakdown.md b/docs/versioned_docs/version-v0.19.0/getting_started/02_breakdown.md index d28a54a1600..f928370b2e8 100644 --- a/docs/versioned_docs/version-v0.19.0/getting_started/02_breakdown.md +++ b/docs/versioned_docs/version-v0.19.0/getting_started/02_breakdown.md @@ -51,7 +51,7 @@ license = "MIT" ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} ``` -Nargo.toml for a [workspace](../modules_packages_crates/workspaces) will look a bit different. For example: +Nargo.toml for a [workspace](../modules_packages_crates/workspaces.md) will look a bit different. For example: ```toml [workspace] @@ -74,7 +74,7 @@ The package section requires a number of fields including: #### Dependencies section -This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies) for more info. +This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies.md)for more info. `./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or verifier contract respectively. diff --git a/docs/versioned_docs/version-v0.19.0/index.md b/docs/versioned_docs/version-v0.19.0/index.md index 380368db036..e8d86020a20 100644 --- a/docs/versioned_docs/version-v0.19.0/index.md +++ b/docs/versioned_docs/version-v0.19.0/index.md @@ -34,7 +34,7 @@ Noir can be used for a variety of purposes. ### Solidity Developers Noir currently includes a command to create a Solidity contract which verifies your Noir program. This will -be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier) command to create +be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier.md) command to create a verifier contract. ### Protocol Developers @@ -97,4 +97,4 @@ Some libraries that are available today include: - [Signed Int](https://github.com/resurgencelabs/signed_int) - a library for accessing a custom Signed Integer data type, allowing access to negative numbers on Noir - [Fraction](https://github.com/resurgencelabs/fraction) - a library for accessing fractional number data type in Noir, allowing results that aren't whole numbers -See the section on [dependencies](./modules_packages_crates/dependencies) for more information. +See the section on [dependencies](./modules_packages_crates/dependencies.md) for more information. diff --git a/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/02_booleans.md b/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/02_booleans.md index 885db167d83..d353606210a 100644 --- a/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/02_booleans.md +++ b/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/02_booleans.md @@ -26,5 +26,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/03_strings.md b/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/03_strings.md index c42f34ec3ad..4360893e9a2 100644 --- a/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/03_strings.md +++ b/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/03_strings.md @@ -16,7 +16,7 @@ keywords: The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`std::println()`. See more about [Logging](../../standard_library/logging). +`std::println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/04_arrays.md b/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/04_arrays.md index bdbd1798bef..1424ca2df14 100644 --- a/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/04_arrays.md +++ b/docs/versioned_docs/version-v0.19.0/language_concepts/data_types/04_arrays.md @@ -56,7 +56,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; diff --git a/docs/versioned_docs/version-v0.19.0/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.19.0/modules_packages_crates/dependencies.md index e91e73a4c4f..87a09293ea8 100644 --- a/docs/versioned_docs/version-v0.19.0/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.19.0/modules_packages_crates/dependencies.md @@ -81,14 +81,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.19.0/nargo/01_commands.md b/docs/versioned_docs/version-v0.19.0/nargo/01_commands.md index 65e2bdb44e3..e2b0af522f4 100644 --- a/docs/versioned_docs/version-v0.19.0/nargo/01_commands.md +++ b/docs/versioned_docs/version-v0.19.0/nargo/01_commands.md @@ -213,7 +213,7 @@ you run `nargo test`. To print `println` statements in tests, use the `--show-ou Takes an optional `--exact` flag which allows you to select tests based on an exact name. -See an example on the [testing page](./testing). +See an example on the [testing page](./testing.md). ### Options diff --git a/docs/versioned_docs/version-v0.19.0/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.19.0/standard_library/black_box_fns.md index e0c6d475c1f..985bb7c879d 100644 --- a/docs/versioned_docs/version-v0.19.0/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.19.0/standard_library/black_box_fns.md @@ -26,20 +26,20 @@ fn sha256(_input : [u8; N]) -> [u8; 32] {} Here is a list of the current black box functions that are supported by UltraPlonk: - AES -- [SHA256](./cryptographic_primitives/hashes#sha256) -- [Schnorr signature verification](./cryptographic_primitives/schnorr) -- [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) -- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) -- [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) -- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) -- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) -- [Compute merkle root](./merkle_trees#compute_merkle_root) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Pedersen Hash](./cryptographic_primitives/hashes.mdx#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes.mdx#pedersen_commitment) +- [HashToField128Security](./cryptographic_primitives/hashes.mdx#hash_to_field) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar.mdx) +- [Compute merkle root](./merkle_trees.md#compute_merkle_root) - AND - XOR - RANGE -- [Keccak256](./cryptographic_primitives/hashes#keccak256) -- [Recursive proof verification](./recursion) +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. To ensure compatibility across backends, the ACVM has fallback implementations of `AND`, `XOR` and `RANGE` defined in its standard library which it can seamlessly fallback to if the backend doesn't support them. diff --git a/docs/versioned_docs/version-v0.19.0/standard_library/recursion.md b/docs/versioned_docs/version-v0.19.0/standard_library/recursion.md index ff4c63acaa7..5e592a2fd89 100644 --- a/docs/versioned_docs/version-v0.19.0/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.19.0/standard_library/recursion.md @@ -15,7 +15,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.19.1/getting_started/01_hello_world.md b/docs/versioned_docs/version-v0.19.1/getting_started/01_hello_world.md index d4daae605a2..34f8cd96fcd 100644 --- a/docs/versioned_docs/version-v0.19.1/getting_started/01_hello_world.md +++ b/docs/versioned_docs/version-v0.19.1/getting_started/01_hello_world.md @@ -74,7 +74,7 @@ x : Field, y : pub Field Program inputs in Noir are private by default (e.g. `x`), but can be labeled public using the keyword `pub` (e.g. `y`). To learn more about private and public values, check the -[Data Types](../language_concepts/data_types) section. +[Data Types](../language_concepts/data_types.md) section. The next line of the program specifies its body: @@ -84,7 +84,7 @@ assert(x != y); The Noir syntax `assert` can be interpreted as something similar to constraints in other zk-contract languages. -For more Noir syntax, check the [Language Concepts](../language_concepts/comments) chapter. +For more Noir syntax, check the [Language Concepts](../language_concepts/comments.md) chapter. ## Build In/Output Files diff --git a/docs/versioned_docs/version-v0.19.1/getting_started/02_breakdown.md b/docs/versioned_docs/version-v0.19.1/getting_started/02_breakdown.md index d28a54a1600..f928370b2e8 100644 --- a/docs/versioned_docs/version-v0.19.1/getting_started/02_breakdown.md +++ b/docs/versioned_docs/version-v0.19.1/getting_started/02_breakdown.md @@ -51,7 +51,7 @@ license = "MIT" ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} ``` -Nargo.toml for a [workspace](../modules_packages_crates/workspaces) will look a bit different. For example: +Nargo.toml for a [workspace](../modules_packages_crates/workspaces.md) will look a bit different. For example: ```toml [workspace] @@ -74,7 +74,7 @@ The package section requires a number of fields including: #### Dependencies section -This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies) for more info. +This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies.md)for more info. `./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or verifier contract respectively. diff --git a/docs/versioned_docs/version-v0.19.1/index.md b/docs/versioned_docs/version-v0.19.1/index.md index 380368db036..e8d86020a20 100644 --- a/docs/versioned_docs/version-v0.19.1/index.md +++ b/docs/versioned_docs/version-v0.19.1/index.md @@ -34,7 +34,7 @@ Noir can be used for a variety of purposes. ### Solidity Developers Noir currently includes a command to create a Solidity contract which verifies your Noir program. This will -be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier) command to create +be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier.md) command to create a verifier contract. ### Protocol Developers @@ -97,4 +97,4 @@ Some libraries that are available today include: - [Signed Int](https://github.com/resurgencelabs/signed_int) - a library for accessing a custom Signed Integer data type, allowing access to negative numbers on Noir - [Fraction](https://github.com/resurgencelabs/fraction) - a library for accessing fractional number data type in Noir, allowing results that aren't whole numbers -See the section on [dependencies](./modules_packages_crates/dependencies) for more information. +See the section on [dependencies](./modules_packages_crates/dependencies.md) for more information. diff --git a/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/02_booleans.md b/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/02_booleans.md index 885db167d83..d353606210a 100644 --- a/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/02_booleans.md +++ b/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/02_booleans.md @@ -26,5 +26,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/03_strings.md b/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/03_strings.md index c42f34ec3ad..4360893e9a2 100644 --- a/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/03_strings.md +++ b/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/03_strings.md @@ -16,7 +16,7 @@ keywords: The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`std::println()`. See more about [Logging](../../standard_library/logging). +`std::println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/04_arrays.md b/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/04_arrays.md index bdbd1798bef..1424ca2df14 100644 --- a/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/04_arrays.md +++ b/docs/versioned_docs/version-v0.19.1/language_concepts/data_types/04_arrays.md @@ -56,7 +56,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; diff --git a/docs/versioned_docs/version-v0.19.1/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.19.1/modules_packages_crates/dependencies.md index e91e73a4c4f..87a09293ea8 100644 --- a/docs/versioned_docs/version-v0.19.1/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.19.1/modules_packages_crates/dependencies.md @@ -81,14 +81,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.19.1/nargo/01_commands.md b/docs/versioned_docs/version-v0.19.1/nargo/01_commands.md index 65e2bdb44e3..e2b0af522f4 100644 --- a/docs/versioned_docs/version-v0.19.1/nargo/01_commands.md +++ b/docs/versioned_docs/version-v0.19.1/nargo/01_commands.md @@ -213,7 +213,7 @@ you run `nargo test`. To print `println` statements in tests, use the `--show-ou Takes an optional `--exact` flag which allows you to select tests based on an exact name. -See an example on the [testing page](./testing). +See an example on the [testing page](./testing.md). ### Options diff --git a/docs/versioned_docs/version-v0.19.1/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.19.1/standard_library/black_box_fns.md index e0c6d475c1f..985bb7c879d 100644 --- a/docs/versioned_docs/version-v0.19.1/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.19.1/standard_library/black_box_fns.md @@ -26,20 +26,20 @@ fn sha256(_input : [u8; N]) -> [u8; 32] {} Here is a list of the current black box functions that are supported by UltraPlonk: - AES -- [SHA256](./cryptographic_primitives/hashes#sha256) -- [Schnorr signature verification](./cryptographic_primitives/schnorr) -- [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) -- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) -- [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) -- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) -- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) -- [Compute merkle root](./merkle_trees#compute_merkle_root) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Pedersen Hash](./cryptographic_primitives/hashes.mdx#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes.mdx#pedersen_commitment) +- [HashToField128Security](./cryptographic_primitives/hashes.mdx#hash_to_field) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar.mdx) +- [Compute merkle root](./merkle_trees.md#compute_merkle_root) - AND - XOR - RANGE -- [Keccak256](./cryptographic_primitives/hashes#keccak256) -- [Recursive proof verification](./recursion) +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. To ensure compatibility across backends, the ACVM has fallback implementations of `AND`, `XOR` and `RANGE` defined in its standard library which it can seamlessly fallback to if the backend doesn't support them. diff --git a/docs/versioned_docs/version-v0.19.1/standard_library/recursion.md b/docs/versioned_docs/version-v0.19.1/standard_library/recursion.md index ff4c63acaa7..5e592a2fd89 100644 --- a/docs/versioned_docs/version-v0.19.1/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.19.1/standard_library/recursion.md @@ -15,7 +15,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.19.2/getting_started/01_hello_world.md b/docs/versioned_docs/version-v0.19.2/getting_started/01_hello_world.md index d4daae605a2..34f8cd96fcd 100644 --- a/docs/versioned_docs/version-v0.19.2/getting_started/01_hello_world.md +++ b/docs/versioned_docs/version-v0.19.2/getting_started/01_hello_world.md @@ -74,7 +74,7 @@ x : Field, y : pub Field Program inputs in Noir are private by default (e.g. `x`), but can be labeled public using the keyword `pub` (e.g. `y`). To learn more about private and public values, check the -[Data Types](../language_concepts/data_types) section. +[Data Types](../language_concepts/data_types.md) section. The next line of the program specifies its body: @@ -84,7 +84,7 @@ assert(x != y); The Noir syntax `assert` can be interpreted as something similar to constraints in other zk-contract languages. -For more Noir syntax, check the [Language Concepts](../language_concepts/comments) chapter. +For more Noir syntax, check the [Language Concepts](../language_concepts/comments.md) chapter. ## Build In/Output Files diff --git a/docs/versioned_docs/version-v0.19.2/getting_started/02_breakdown.md b/docs/versioned_docs/version-v0.19.2/getting_started/02_breakdown.md index d28a54a1600..f928370b2e8 100644 --- a/docs/versioned_docs/version-v0.19.2/getting_started/02_breakdown.md +++ b/docs/versioned_docs/version-v0.19.2/getting_started/02_breakdown.md @@ -51,7 +51,7 @@ license = "MIT" ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} ``` -Nargo.toml for a [workspace](../modules_packages_crates/workspaces) will look a bit different. For example: +Nargo.toml for a [workspace](../modules_packages_crates/workspaces.md) will look a bit different. For example: ```toml [workspace] @@ -74,7 +74,7 @@ The package section requires a number of fields including: #### Dependencies section -This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies) for more info. +This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies.md)for more info. `./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or verifier contract respectively. diff --git a/docs/versioned_docs/version-v0.19.2/index.md b/docs/versioned_docs/version-v0.19.2/index.md index 380368db036..e8d86020a20 100644 --- a/docs/versioned_docs/version-v0.19.2/index.md +++ b/docs/versioned_docs/version-v0.19.2/index.md @@ -34,7 +34,7 @@ Noir can be used for a variety of purposes. ### Solidity Developers Noir currently includes a command to create a Solidity contract which verifies your Noir program. This will -be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier) command to create +be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier.md) command to create a verifier contract. ### Protocol Developers @@ -97,4 +97,4 @@ Some libraries that are available today include: - [Signed Int](https://github.com/resurgencelabs/signed_int) - a library for accessing a custom Signed Integer data type, allowing access to negative numbers on Noir - [Fraction](https://github.com/resurgencelabs/fraction) - a library for accessing fractional number data type in Noir, allowing results that aren't whole numbers -See the section on [dependencies](./modules_packages_crates/dependencies) for more information. +See the section on [dependencies](./modules_packages_crates/dependencies.md) for more information. diff --git a/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/02_booleans.md b/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/02_booleans.md index 885db167d83..d353606210a 100644 --- a/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/02_booleans.md +++ b/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/02_booleans.md @@ -26,5 +26,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/03_strings.md b/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/03_strings.md index c42f34ec3ad..4360893e9a2 100644 --- a/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/03_strings.md +++ b/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/03_strings.md @@ -16,7 +16,7 @@ keywords: The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`std::println()`. See more about [Logging](../../standard_library/logging). +`std::println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/04_arrays.md b/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/04_arrays.md index bdbd1798bef..1424ca2df14 100644 --- a/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/04_arrays.md +++ b/docs/versioned_docs/version-v0.19.2/language_concepts/data_types/04_arrays.md @@ -56,7 +56,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; diff --git a/docs/versioned_docs/version-v0.19.2/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.19.2/modules_packages_crates/dependencies.md index e91e73a4c4f..87a09293ea8 100644 --- a/docs/versioned_docs/version-v0.19.2/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.19.2/modules_packages_crates/dependencies.md @@ -81,14 +81,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.19.2/nargo/01_commands.md b/docs/versioned_docs/version-v0.19.2/nargo/01_commands.md index 65e2bdb44e3..e2b0af522f4 100644 --- a/docs/versioned_docs/version-v0.19.2/nargo/01_commands.md +++ b/docs/versioned_docs/version-v0.19.2/nargo/01_commands.md @@ -213,7 +213,7 @@ you run `nargo test`. To print `println` statements in tests, use the `--show-ou Takes an optional `--exact` flag which allows you to select tests based on an exact name. -See an example on the [testing page](./testing). +See an example on the [testing page](./testing.md). ### Options diff --git a/docs/versioned_docs/version-v0.19.2/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.19.2/standard_library/black_box_fns.md index e0c6d475c1f..985bb7c879d 100644 --- a/docs/versioned_docs/version-v0.19.2/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.19.2/standard_library/black_box_fns.md @@ -26,20 +26,20 @@ fn sha256(_input : [u8; N]) -> [u8; 32] {} Here is a list of the current black box functions that are supported by UltraPlonk: - AES -- [SHA256](./cryptographic_primitives/hashes#sha256) -- [Schnorr signature verification](./cryptographic_primitives/schnorr) -- [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) -- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) -- [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) -- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) -- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) -- [Compute merkle root](./merkle_trees#compute_merkle_root) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Pedersen Hash](./cryptographic_primitives/hashes.mdx#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes.mdx#pedersen_commitment) +- [HashToField128Security](./cryptographic_primitives/hashes.mdx#hash_to_field) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar.mdx) +- [Compute merkle root](./merkle_trees.md#compute_merkle_root) - AND - XOR - RANGE -- [Keccak256](./cryptographic_primitives/hashes#keccak256) -- [Recursive proof verification](./recursion) +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. To ensure compatibility across backends, the ACVM has fallback implementations of `AND`, `XOR` and `RANGE` defined in its standard library which it can seamlessly fallback to if the backend doesn't support them. diff --git a/docs/versioned_docs/version-v0.19.2/standard_library/recursion.md b/docs/versioned_docs/version-v0.19.2/standard_library/recursion.md index ff4c63acaa7..5e592a2fd89 100644 --- a/docs/versioned_docs/version-v0.19.2/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.19.2/standard_library/recursion.md @@ -15,7 +15,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.19.3/getting_started/01_hello_world.md b/docs/versioned_docs/version-v0.19.3/getting_started/01_hello_world.md index d4daae605a2..34f8cd96fcd 100644 --- a/docs/versioned_docs/version-v0.19.3/getting_started/01_hello_world.md +++ b/docs/versioned_docs/version-v0.19.3/getting_started/01_hello_world.md @@ -74,7 +74,7 @@ x : Field, y : pub Field Program inputs in Noir are private by default (e.g. `x`), but can be labeled public using the keyword `pub` (e.g. `y`). To learn more about private and public values, check the -[Data Types](../language_concepts/data_types) section. +[Data Types](../language_concepts/data_types.md) section. The next line of the program specifies its body: @@ -84,7 +84,7 @@ assert(x != y); The Noir syntax `assert` can be interpreted as something similar to constraints in other zk-contract languages. -For more Noir syntax, check the [Language Concepts](../language_concepts/comments) chapter. +For more Noir syntax, check the [Language Concepts](../language_concepts/comments.md) chapter. ## Build In/Output Files diff --git a/docs/versioned_docs/version-v0.19.3/getting_started/02_breakdown.md b/docs/versioned_docs/version-v0.19.3/getting_started/02_breakdown.md index 7a7fb876c35..10422029661 100644 --- a/docs/versioned_docs/version-v0.19.3/getting_started/02_breakdown.md +++ b/docs/versioned_docs/version-v0.19.3/getting_started/02_breakdown.md @@ -51,7 +51,7 @@ license = "MIT" ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} ``` -Nargo.toml for a [workspace](../modules_packages_crates/workspaces) will look a bit different. For example: +Nargo.toml for a [workspace](../modules_packages_crates/workspaces.md) will look a bit different. For example: ```toml [workspace] @@ -74,7 +74,7 @@ The package section requires a number of fields including: #### Dependencies section -This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies) for more info. +This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies.md)for more info. `./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or verifier contract respectively. diff --git a/docs/versioned_docs/version-v0.19.3/index.md b/docs/versioned_docs/version-v0.19.3/index.md index 380368db036..e8d86020a20 100644 --- a/docs/versioned_docs/version-v0.19.3/index.md +++ b/docs/versioned_docs/version-v0.19.3/index.md @@ -34,7 +34,7 @@ Noir can be used for a variety of purposes. ### Solidity Developers Noir currently includes a command to create a Solidity contract which verifies your Noir program. This will -be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier) command to create +be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier.md) command to create a verifier contract. ### Protocol Developers @@ -97,4 +97,4 @@ Some libraries that are available today include: - [Signed Int](https://github.com/resurgencelabs/signed_int) - a library for accessing a custom Signed Integer data type, allowing access to negative numbers on Noir - [Fraction](https://github.com/resurgencelabs/fraction) - a library for accessing fractional number data type in Noir, allowing results that aren't whole numbers -See the section on [dependencies](./modules_packages_crates/dependencies) for more information. +See the section on [dependencies](./modules_packages_crates/dependencies.md) for more information. diff --git a/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/02_booleans.md b/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/02_booleans.md index 885db167d83..d353606210a 100644 --- a/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/02_booleans.md +++ b/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/02_booleans.md @@ -26,5 +26,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/03_strings.md b/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/03_strings.md index c42f34ec3ad..4360893e9a2 100644 --- a/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/03_strings.md +++ b/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/03_strings.md @@ -16,7 +16,7 @@ keywords: The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`std::println()`. See more about [Logging](../../standard_library/logging). +`std::println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/04_arrays.md b/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/04_arrays.md index bdbd1798bef..1424ca2df14 100644 --- a/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/04_arrays.md +++ b/docs/versioned_docs/version-v0.19.3/language_concepts/data_types/04_arrays.md @@ -56,7 +56,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; diff --git a/docs/versioned_docs/version-v0.19.3/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.19.3/modules_packages_crates/dependencies.md index e91e73a4c4f..87a09293ea8 100644 --- a/docs/versioned_docs/version-v0.19.3/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.19.3/modules_packages_crates/dependencies.md @@ -81,14 +81,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.19.3/nargo/01_commands.md b/docs/versioned_docs/version-v0.19.3/nargo/01_commands.md index 65e2bdb44e3..e2b0af522f4 100644 --- a/docs/versioned_docs/version-v0.19.3/nargo/01_commands.md +++ b/docs/versioned_docs/version-v0.19.3/nargo/01_commands.md @@ -213,7 +213,7 @@ you run `nargo test`. To print `println` statements in tests, use the `--show-ou Takes an optional `--exact` flag which allows you to select tests based on an exact name. -See an example on the [testing page](./testing). +See an example on the [testing page](./testing.md). ### Options diff --git a/docs/versioned_docs/version-v0.19.3/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.19.3/standard_library/black_box_fns.md index e0c6d475c1f..985bb7c879d 100644 --- a/docs/versioned_docs/version-v0.19.3/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.19.3/standard_library/black_box_fns.md @@ -26,20 +26,20 @@ fn sha256(_input : [u8; N]) -> [u8; 32] {} Here is a list of the current black box functions that are supported by UltraPlonk: - AES -- [SHA256](./cryptographic_primitives/hashes#sha256) -- [Schnorr signature verification](./cryptographic_primitives/schnorr) -- [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) -- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) -- [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) -- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) -- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) -- [Compute merkle root](./merkle_trees#compute_merkle_root) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Pedersen Hash](./cryptographic_primitives/hashes.mdx#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes.mdx#pedersen_commitment) +- [HashToField128Security](./cryptographic_primitives/hashes.mdx#hash_to_field) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar.mdx) +- [Compute merkle root](./merkle_trees.md#compute_merkle_root) - AND - XOR - RANGE -- [Keccak256](./cryptographic_primitives/hashes#keccak256) -- [Recursive proof verification](./recursion) +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. To ensure compatibility across backends, the ACVM has fallback implementations of `AND`, `XOR` and `RANGE` defined in its standard library which it can seamlessly fallback to if the backend doesn't support them. diff --git a/docs/versioned_docs/version-v0.19.3/standard_library/recursion.md b/docs/versioned_docs/version-v0.19.3/standard_library/recursion.md index ff4c63acaa7..5e592a2fd89 100644 --- a/docs/versioned_docs/version-v0.19.3/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.19.3/standard_library/recursion.md @@ -15,7 +15,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.19.4/getting_started/01_hello_world.md b/docs/versioned_docs/version-v0.19.4/getting_started/01_hello_world.md index d4daae605a2..34f8cd96fcd 100644 --- a/docs/versioned_docs/version-v0.19.4/getting_started/01_hello_world.md +++ b/docs/versioned_docs/version-v0.19.4/getting_started/01_hello_world.md @@ -74,7 +74,7 @@ x : Field, y : pub Field Program inputs in Noir are private by default (e.g. `x`), but can be labeled public using the keyword `pub` (e.g. `y`). To learn more about private and public values, check the -[Data Types](../language_concepts/data_types) section. +[Data Types](../language_concepts/data_types.md) section. The next line of the program specifies its body: @@ -84,7 +84,7 @@ assert(x != y); The Noir syntax `assert` can be interpreted as something similar to constraints in other zk-contract languages. -For more Noir syntax, check the [Language Concepts](../language_concepts/comments) chapter. +For more Noir syntax, check the [Language Concepts](../language_concepts/comments.md) chapter. ## Build In/Output Files diff --git a/docs/versioned_docs/version-v0.19.4/getting_started/02_breakdown.md b/docs/versioned_docs/version-v0.19.4/getting_started/02_breakdown.md index d28a54a1600..f928370b2e8 100644 --- a/docs/versioned_docs/version-v0.19.4/getting_started/02_breakdown.md +++ b/docs/versioned_docs/version-v0.19.4/getting_started/02_breakdown.md @@ -51,7 +51,7 @@ license = "MIT" ecrecover = {tag = "v0.9.0", git = "https://github.com/colinnielsen/ecrecover-noir.git"} ``` -Nargo.toml for a [workspace](../modules_packages_crates/workspaces) will look a bit different. For example: +Nargo.toml for a [workspace](../modules_packages_crates/workspaces.md) will look a bit different. For example: ```toml [workspace] @@ -74,7 +74,7 @@ The package section requires a number of fields including: #### Dependencies section -This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies) for more info. +This is where you will specify any dependencies for your project. See the [Dependencies page](../modules_packages_crates/dependencies.md)for more info. `./proofs/` and `./contract/` directories will not be immediately visible until you create a proof or verifier contract respectively. diff --git a/docs/versioned_docs/version-v0.19.4/index.md b/docs/versioned_docs/version-v0.19.4/index.md index 380368db036..e8d86020a20 100644 --- a/docs/versioned_docs/version-v0.19.4/index.md +++ b/docs/versioned_docs/version-v0.19.4/index.md @@ -34,7 +34,7 @@ Noir can be used for a variety of purposes. ### Solidity Developers Noir currently includes a command to create a Solidity contract which verifies your Noir program. This will -be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier) command to create +be modularized in the future; however, as of the alpha, you can use the [`nargo codegen-verifier`](./nargo/commands#nargo-codegen-verifier.md) command to create a verifier contract. ### Protocol Developers @@ -97,4 +97,4 @@ Some libraries that are available today include: - [Signed Int](https://github.com/resurgencelabs/signed_int) - a library for accessing a custom Signed Integer data type, allowing access to negative numbers on Noir - [Fraction](https://github.com/resurgencelabs/fraction) - a library for accessing fractional number data type in Noir, allowing results that aren't whole numbers -See the section on [dependencies](./modules_packages_crates/dependencies) for more information. +See the section on [dependencies](./modules_packages_crates/dependencies.md) for more information. diff --git a/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/02_booleans.md b/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/02_booleans.md index 885db167d83..d353606210a 100644 --- a/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/02_booleans.md +++ b/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/02_booleans.md @@ -26,5 +26,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/03_strings.md b/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/03_strings.md index b4c75942bb8..baa3f205094 100644 --- a/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/03_strings.md +++ b/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/03_strings.md @@ -15,7 +15,7 @@ keywords: The string type is a fixed length value defined with `str`. -You can use strings in `assert()` functions or print them with `std::println()`. See more about [Logging](../../standard_library/logging). +You can use strings in `assert()` functions or print them with `std::println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/04_arrays.md b/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/04_arrays.md index bdbd1798bef..1424ca2df14 100644 --- a/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/04_arrays.md +++ b/docs/versioned_docs/version-v0.19.4/language_concepts/data_types/04_arrays.md @@ -56,7 +56,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; diff --git a/docs/versioned_docs/version-v0.19.4/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.19.4/modules_packages_crates/dependencies.md index e91e73a4c4f..87a09293ea8 100644 --- a/docs/versioned_docs/version-v0.19.4/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.19.4/modules_packages_crates/dependencies.md @@ -81,14 +81,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.19.4/nargo/01_commands.md b/docs/versioned_docs/version-v0.19.4/nargo/01_commands.md index 65e2bdb44e3..e2b0af522f4 100644 --- a/docs/versioned_docs/version-v0.19.4/nargo/01_commands.md +++ b/docs/versioned_docs/version-v0.19.4/nargo/01_commands.md @@ -213,7 +213,7 @@ you run `nargo test`. To print `println` statements in tests, use the `--show-ou Takes an optional `--exact` flag which allows you to select tests based on an exact name. -See an example on the [testing page](./testing). +See an example on the [testing page](./testing.md). ### Options diff --git a/docs/versioned_docs/version-v0.19.4/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.19.4/standard_library/black_box_fns.md index e0c6d475c1f..985bb7c879d 100644 --- a/docs/versioned_docs/version-v0.19.4/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.19.4/standard_library/black_box_fns.md @@ -26,20 +26,20 @@ fn sha256(_input : [u8; N]) -> [u8; 32] {} Here is a list of the current black box functions that are supported by UltraPlonk: - AES -- [SHA256](./cryptographic_primitives/hashes#sha256) -- [Schnorr signature verification](./cryptographic_primitives/schnorr) -- [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) -- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) -- [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) -- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) -- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) -- [Compute merkle root](./merkle_trees#compute_merkle_root) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Pedersen Hash](./cryptographic_primitives/hashes.mdx#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes.mdx#pedersen_commitment) +- [HashToField128Security](./cryptographic_primitives/hashes.mdx#hash_to_field) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar.mdx) +- [Compute merkle root](./merkle_trees.md#compute_merkle_root) - AND - XOR - RANGE -- [Keccak256](./cryptographic_primitives/hashes#keccak256) -- [Recursive proof verification](./recursion) +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. To ensure compatibility across backends, the ACVM has fallback implementations of `AND`, `XOR` and `RANGE` defined in its standard library which it can seamlessly fallback to if the backend doesn't support them. diff --git a/docs/versioned_docs/version-v0.19.4/standard_library/recursion.md b/docs/versioned_docs/version-v0.19.4/standard_library/recursion.md index ff4c63acaa7..5e592a2fd89 100644 --- a/docs/versioned_docs/version-v0.19.4/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.19.4/standard_library/recursion.md @@ -15,7 +15,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.22.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.22.0/noir/modules_packages_crates/dependencies.md index a37dc401b7d..d9d21ef0485 100644 --- a/docs/versioned_docs/version-v0.22.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.22.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.22.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.22.0/noir/standard_library/black_box_fns.md index e0c6d475c1f..985bb7c879d 100644 --- a/docs/versioned_docs/version-v0.22.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.22.0/noir/standard_library/black_box_fns.md @@ -26,20 +26,20 @@ fn sha256(_input : [u8; N]) -> [u8; 32] {} Here is a list of the current black box functions that are supported by UltraPlonk: - AES -- [SHA256](./cryptographic_primitives/hashes#sha256) -- [Schnorr signature verification](./cryptographic_primitives/schnorr) -- [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) -- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) -- [HashToField128Security](./cryptographic_primitives/hashes#hash_to_field) -- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) -- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) -- [Compute merkle root](./merkle_trees#compute_merkle_root) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Pedersen Hash](./cryptographic_primitives/hashes.mdx#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes.mdx#pedersen_commitment) +- [HashToField128Security](./cryptographic_primitives/hashes.mdx#hash_to_field) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar.mdx) +- [Compute merkle root](./merkle_trees.md#compute_merkle_root) - AND - XOR - RANGE -- [Keccak256](./cryptographic_primitives/hashes#keccak256) -- [Recursive proof verification](./recursion) +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. To ensure compatibility across backends, the ACVM has fallback implementations of `AND`, `XOR` and `RANGE` defined in its standard library which it can seamlessly fallback to if the backend doesn't support them. diff --git a/docs/versioned_docs/version-v0.22.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.22.0/noir/standard_library/recursion.md index 67962082a8f..4a004fd3664 100644 --- a/docs/versioned_docs/version-v0.22.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.22.0/noir/standard_library/recursion.md @@ -15,7 +15,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/arrays.md b/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/arrays.md index 075d39dadd4..4c80d50ed01 100644 --- a/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; diff --git a/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/booleans.md b/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/strings.md b/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/strings.md index 8d76d4ca654..dd6c844f6ae 100644 --- a/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/strings.md +++ b/docs/versioned_docs/version-v0.22.0/noir/syntax/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`std::println()`. See more about [Logging](../../standard_library/logging). +`std::println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/arrays.md b/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/arrays.md index 7f275a2d771..d95346454a9 100644 --- a/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = []; ``` diff --git a/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/booleans.md b/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/strings.md b/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/strings.md +++ b/docs/versioned_docs/version-v0.23.0/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.23.0/noir/concepts/generics.md b/docs/versioned_docs/version-v0.23.0/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/versioned_docs/version-v0.23.0/noir/concepts/generics.md +++ b/docs/versioned_docs/version-v0.23.0/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/versioned_docs/version-v0.23.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.23.0/noir/modules_packages_crates/dependencies.md index a37dc401b7d..d9d21ef0485 100644 --- a/docs/versioned_docs/version-v0.23.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.23.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.23.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.23.0/noir/standard_library/black_box_fns.md index eae8744abf0..e8b62f21d4e 100644 --- a/docs/versioned_docs/version-v0.23.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.23.0/noir/standard_library/black_box_fns.md @@ -12,19 +12,19 @@ The ACVM spec defines a set of blackbox functions which backends will be expecte Here is a list of the current black box functions: -- [SHA256](./cryptographic_primitives/hashes#sha256) -- [Schnorr signature verification](./cryptographic_primitives/schnorr) -- [Blake2s](./cryptographic_primitives/hashes#blake2s) -- [Blake3](./cryptographic_primitives/hashes#blake3) -- [Pedersen Hash](./cryptographic_primitives/hashes#pedersen_hash) -- [Pedersen Commitment](./cryptographic_primitives/hashes#pedersen_commitment) -- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification) -- [Fixed base scalar multiplication](./cryptographic_primitives/scalar) +- [SHA256](./cryptographic_primitives/hashes.mdx#sha256) +- [Schnorr signature verification](./cryptographic_primitives/schnorr.mdx) +- [Blake2s](./cryptographic_primitives/hashes.mdx#blake2s) +- [Blake3](./cryptographic_primitives/hashes.mdx#blake3) +- [Pedersen Hash](./cryptographic_primitives/hashes.mdx#pedersen_hash) +- [Pedersen Commitment](./cryptographic_primitives/hashes.mdx#pedersen_commitment) +- [ECDSA signature verification](./cryptographic_primitives/ecdsa_sig_verification.mdx) +- [Fixed base scalar multiplication](./cryptographic_primitives/scalar.mdx) - AND - XOR - RANGE -- [Keccak256](./cryptographic_primitives/hashes#keccak256) -- [Recursive proof verification](./recursion) +- [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/versioned_docs/version-v0.23.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.23.0/noir/standard_library/recursion.md index f252150c8b5..4390bda4a26 100644 --- a/docs/versioned_docs/version-v0.23.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.23.0/noir/standard_library/recursion.md @@ -15,7 +15,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/arrays.md b/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/arrays.md index a8bd338e736..ca54d82b26b 100644 --- a/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = []; ``` diff --git a/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/booleans.md b/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/strings.md b/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/strings.md +++ b/docs/versioned_docs/version-v0.24.0/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.24.0/noir/concepts/generics.md b/docs/versioned_docs/version-v0.24.0/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/versioned_docs/version-v0.24.0/noir/concepts/generics.md +++ b/docs/versioned_docs/version-v0.24.0/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/versioned_docs/version-v0.24.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.24.0/noir/modules_packages_crates/dependencies.md index a37dc401b7d..d9d21ef0485 100644 --- a/docs/versioned_docs/version-v0.24.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.24.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.24.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.24.0/noir/standard_library/black_box_fns.md index be8c65679c3..e8b62f21d4e 100644 --- a/docs/versioned_docs/version-v0.24.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.24.0/noir/standard_library/black_box_fns.md @@ -24,7 +24,7 @@ Here is a list of the current black box functions: - XOR - RANGE - [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) -- [Recursive proof verification](./recursion) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/versioned_docs/version-v0.24.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.24.0/noir/standard_library/recursion.md index 9337499dac8..ed2ed01fceb 100644 --- a/docs/versioned_docs/version-v0.24.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.24.0/noir/standard_library/recursion.md @@ -35,7 +35,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/arrays.md b/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/arrays.md index a8bd338e736..ca54d82b26b 100644 --- a/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = []; ``` diff --git a/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/booleans.md b/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/strings.md b/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/strings.md +++ b/docs/versioned_docs/version-v0.25.0/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.25.0/noir/concepts/generics.md b/docs/versioned_docs/version-v0.25.0/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/versioned_docs/version-v0.25.0/noir/concepts/generics.md +++ b/docs/versioned_docs/version-v0.25.0/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/dependencies.md index 04c1703d929..2c028d85853 100644 --- a/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.25.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.25.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.25.0/noir/standard_library/black_box_fns.md index be8c65679c3..e8b62f21d4e 100644 --- a/docs/versioned_docs/version-v0.25.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.25.0/noir/standard_library/black_box_fns.md @@ -24,7 +24,7 @@ Here is a list of the current black box functions: - XOR - RANGE - [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) -- [Recursive proof verification](./recursion) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/versioned_docs/version-v0.25.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.25.0/noir/standard_library/recursion.md index 9337499dac8..ed2ed01fceb 100644 --- a/docs/versioned_docs/version-v0.25.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.25.0/noir/standard_library/recursion.md @@ -35,7 +35,7 @@ fn verify_proof(_verification_key : [Field], _proof : [Field], _public_input : F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/arrays.md b/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/arrays.md index efce3e95d32..95d749053e2 100644 --- a/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = &[]; ``` diff --git a/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/booleans.md b/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/strings.md b/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/strings.md +++ b/docs/versioned_docs/version-v0.26.0/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.26.0/noir/concepts/generics.md b/docs/versioned_docs/version-v0.26.0/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/versioned_docs/version-v0.26.0/noir/concepts/generics.md +++ b/docs/versioned_docs/version-v0.26.0/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/versioned_docs/version-v0.26.0/noir/concepts/unconstrained.md b/docs/versioned_docs/version-v0.26.0/noir/concepts/unconstrained.md index b8e71fe65f0..96f824c5e42 100644 --- a/docs/versioned_docs/version-v0.26.0/noir/concepts/unconstrained.md +++ b/docs/versioned_docs/version-v0.26.0/noir/concepts/unconstrained.md @@ -96,4 +96,4 @@ Generally we want to use brillig whenever there's something that's easy to verif ## Break and Continue -In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow/#break-and-continue) +In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow.md#break-and-continue) diff --git a/docs/versioned_docs/version-v0.26.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.26.0/noir/modules_packages_crates/dependencies.md index 04c1703d929..2c028d85853 100644 --- a/docs/versioned_docs/version-v0.26.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.26.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.26.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.26.0/noir/standard_library/black_box_fns.md index be8c65679c3..e8b62f21d4e 100644 --- a/docs/versioned_docs/version-v0.26.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.26.0/noir/standard_library/black_box_fns.md @@ -24,7 +24,7 @@ Here is a list of the current black box functions: - XOR - RANGE - [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) -- [Recursive proof verification](./recursion) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/versioned_docs/version-v0.26.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.26.0/noir/standard_library/recursion.md index a93894043dc..f33c285cf4e 100644 --- a/docs/versioned_docs/version-v0.26.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.26.0/noir/standard_library/recursion.md @@ -35,7 +35,7 @@ pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/arrays.md b/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/arrays.md index efce3e95d32..95d749053e2 100644 --- a/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = &[]; ``` diff --git a/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/booleans.md b/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/strings.md b/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/strings.md +++ b/docs/versioned_docs/version-v0.27.0/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.27.0/noir/concepts/generics.md b/docs/versioned_docs/version-v0.27.0/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/versioned_docs/version-v0.27.0/noir/concepts/generics.md +++ b/docs/versioned_docs/version-v0.27.0/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/versioned_docs/version-v0.27.0/noir/concepts/unconstrained.md b/docs/versioned_docs/version-v0.27.0/noir/concepts/unconstrained.md index b8e71fe65f0..96f824c5e42 100644 --- a/docs/versioned_docs/version-v0.27.0/noir/concepts/unconstrained.md +++ b/docs/versioned_docs/version-v0.27.0/noir/concepts/unconstrained.md @@ -96,4 +96,4 @@ Generally we want to use brillig whenever there's something that's easy to verif ## Break and Continue -In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow/#break-and-continue) +In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow.md#break-and-continue) diff --git a/docs/versioned_docs/version-v0.27.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.27.0/noir/modules_packages_crates/dependencies.md index 04c1703d929..2c028d85853 100644 --- a/docs/versioned_docs/version-v0.27.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.27.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.27.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.27.0/noir/standard_library/black_box_fns.md index be8c65679c3..e8b62f21d4e 100644 --- a/docs/versioned_docs/version-v0.27.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.27.0/noir/standard_library/black_box_fns.md @@ -24,7 +24,7 @@ Here is a list of the current black box functions: - XOR - RANGE - [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) -- [Recursive proof verification](./recursion) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/versioned_docs/version-v0.27.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.27.0/noir/standard_library/recursion.md index a93894043dc..f33c285cf4e 100644 --- a/docs/versioned_docs/version-v0.27.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.27.0/noir/standard_library/recursion.md @@ -35,7 +35,7 @@ pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/arrays.md b/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/arrays.md index efce3e95d32..95d749053e2 100644 --- a/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = &[]; ``` diff --git a/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/booleans.md b/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/strings.md b/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/strings.md +++ b/docs/versioned_docs/version-v0.28.0/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.28.0/noir/concepts/generics.md b/docs/versioned_docs/version-v0.28.0/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/versioned_docs/version-v0.28.0/noir/concepts/generics.md +++ b/docs/versioned_docs/version-v0.28.0/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/versioned_docs/version-v0.28.0/noir/concepts/unconstrained.md b/docs/versioned_docs/version-v0.28.0/noir/concepts/unconstrained.md index b8e71fe65f0..96f824c5e42 100644 --- a/docs/versioned_docs/version-v0.28.0/noir/concepts/unconstrained.md +++ b/docs/versioned_docs/version-v0.28.0/noir/concepts/unconstrained.md @@ -96,4 +96,4 @@ Generally we want to use brillig whenever there's something that's easy to verif ## Break and Continue -In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow/#break-and-continue) +In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow.md#break-and-continue) diff --git a/docs/versioned_docs/version-v0.28.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.28.0/noir/modules_packages_crates/dependencies.md index 04c1703d929..2c028d85853 100644 --- a/docs/versioned_docs/version-v0.28.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.28.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.28.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.28.0/noir/standard_library/black_box_fns.md index be8c65679c3..e8b62f21d4e 100644 --- a/docs/versioned_docs/version-v0.28.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.28.0/noir/standard_library/black_box_fns.md @@ -24,7 +24,7 @@ Here is a list of the current black box functions: - XOR - RANGE - [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) -- [Recursive proof verification](./recursion) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/versioned_docs/version-v0.28.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.28.0/noir/standard_library/recursion.md index a93894043dc..f33c285cf4e 100644 --- a/docs/versioned_docs/version-v0.28.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.28.0/noir/standard_library/recursion.md @@ -35,7 +35,7 @@ pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.28.0/tooling/debugger.md b/docs/versioned_docs/version-v0.28.0/tooling/debugger.md index 7c158d949d1..9b7565ba9ff 100644 --- a/docs/versioned_docs/version-v0.28.0/tooling/debugger.md +++ b/docs/versioned_docs/version-v0.28.0/tooling/debugger.md @@ -12,7 +12,7 @@ There are currently two ways of debugging Noir programs: 1. From VS Code, via the [vscode-noir](https://github.com/noir-lang/vscode-noir) extension. You can install it via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir). 2. Via the REPL debugger, which ships with Nargo. -In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/installation) and vscode-noir: +In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/installation/index.md) and vscode-noir: - Noir & Nargo ≥0.28.0 - Noir's VS Code extension ≥0.0.11 diff --git a/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/arrays.md b/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/arrays.md index efce3e95d32..95d749053e2 100644 --- a/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = &[]; ``` diff --git a/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/booleans.md b/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/strings.md b/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/strings.md +++ b/docs/versioned_docs/version-v0.29.0/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.29.0/noir/concepts/generics.md b/docs/versioned_docs/version-v0.29.0/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/versioned_docs/version-v0.29.0/noir/concepts/generics.md +++ b/docs/versioned_docs/version-v0.29.0/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/versioned_docs/version-v0.29.0/noir/concepts/unconstrained.md b/docs/versioned_docs/version-v0.29.0/noir/concepts/unconstrained.md index b8e71fe65f0..96f824c5e42 100644 --- a/docs/versioned_docs/version-v0.29.0/noir/concepts/unconstrained.md +++ b/docs/versioned_docs/version-v0.29.0/noir/concepts/unconstrained.md @@ -96,4 +96,4 @@ Generally we want to use brillig whenever there's something that's easy to verif ## Break and Continue -In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow/#break-and-continue) +In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow.md#break-and-continue) diff --git a/docs/versioned_docs/version-v0.29.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.29.0/noir/modules_packages_crates/dependencies.md index 04c1703d929..2c028d85853 100644 --- a/docs/versioned_docs/version-v0.29.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.29.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.29.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.29.0/noir/standard_library/black_box_fns.md index be8c65679c3..e8b62f21d4e 100644 --- a/docs/versioned_docs/version-v0.29.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.29.0/noir/standard_library/black_box_fns.md @@ -24,7 +24,7 @@ Here is a list of the current black box functions: - XOR - RANGE - [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) -- [Recursive proof verification](./recursion) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/versioned_docs/version-v0.29.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.29.0/noir/standard_library/recursion.md index a93894043dc..f33c285cf4e 100644 --- a/docs/versioned_docs/version-v0.29.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.29.0/noir/standard_library/recursion.md @@ -35,7 +35,7 @@ pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.29.0/tooling/debugger.md b/docs/versioned_docs/version-v0.29.0/tooling/debugger.md index 7c158d949d1..9b7565ba9ff 100644 --- a/docs/versioned_docs/version-v0.29.0/tooling/debugger.md +++ b/docs/versioned_docs/version-v0.29.0/tooling/debugger.md @@ -12,7 +12,7 @@ There are currently two ways of debugging Noir programs: 1. From VS Code, via the [vscode-noir](https://github.com/noir-lang/vscode-noir) extension. You can install it via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir). 2. Via the REPL debugger, which ships with Nargo. -In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/installation) and vscode-noir: +In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/installation/index.md) and vscode-noir: - Noir & Nargo ≥0.28.0 - Noir's VS Code extension ≥0.0.11 diff --git a/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/arrays.md b/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/arrays.md index efce3e95d32..95d749053e2 100644 --- a/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/arrays.md +++ b/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/arrays.md @@ -57,7 +57,7 @@ You can instantiate a new array of a fixed size with the same value repeated for let array: [Field; 32] = [0; 32]; ``` -Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices), you can just call `as_slice` on your array: +Like in Rust, arrays in Noir are a fixed size. However, if you wish to convert an array to a [slice](./slices.mdx), you can just call `as_slice` on your array: ```rust let array: [Field; 32] = [0; 32]; @@ -70,7 +70,9 @@ You can define multidimensional arrays: let array : [[Field; 2]; 2]; let element = array[0][0]; ``` + However, multidimensional slices are not supported. For example, the following code will error at compile time: + ```rust let slice : [[Field]] = &[]; ``` diff --git a/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/booleans.md b/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/booleans.md index 69826fcd724..7211716f63e 100644 --- a/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/booleans.md +++ b/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/booleans.md @@ -27,5 +27,5 @@ fn main() { > `false` in _Verifier.toml_. The boolean type is most commonly used in conditionals like `if` expressions and `assert` -statements. More about conditionals is covered in the [Control Flow](../control_flow) and -[Assert Function](../assert) sections. +statements. More about conditionals is covered in the [Control Flow](../control_flow.md) and +[Assert Function](../assert.md) sections. diff --git a/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/strings.md b/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/strings.md index 311dfd64416..8ab5825a4c4 100644 --- a/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/strings.md +++ b/docs/versioned_docs/version-v0.30.0/noir/concepts/data_types/strings.md @@ -17,7 +17,7 @@ sidebar_position: 3 The string type is a fixed length value defined with `str`. You can use strings in `assert()` functions or print them with -`println()`. See more about [Logging](../../standard_library/logging). +`println()`. See more about [Logging](../../standard_library/logging.md). ```rust use dep::std; diff --git a/docs/versioned_docs/version-v0.30.0/noir/concepts/generics.md b/docs/versioned_docs/version-v0.30.0/noir/concepts/generics.md index ddd42bf1f9b..0c1c27a2221 100644 --- a/docs/versioned_docs/version-v0.30.0/noir/concepts/generics.md +++ b/docs/versioned_docs/version-v0.30.0/noir/concepts/generics.md @@ -73,7 +73,7 @@ impl BigInt { Since a generic type `T` can represent any type, how can we call functions on the underlying type? In other words, how can we go from "any type `T`" to "any type `T` that has certain methods available?" -This is what [traits](../concepts/traits) are for in Noir. Here's an example of a function generic over +This is what [traits](../concepts/traits.md) are for in Noir. Here's an example of a function generic over any type `T` that implements the `Eq` trait for equality: ```rust @@ -103,4 +103,4 @@ impl Eq for MyStruct { } ``` -You can find more details on traits and trait implementations on the [traits page](../concepts/traits). +You can find more details on traits and trait implementations on the [traits page](../concepts/traits.md). diff --git a/docs/versioned_docs/version-v0.30.0/noir/concepts/unconstrained.md b/docs/versioned_docs/version-v0.30.0/noir/concepts/unconstrained.md index b8e71fe65f0..96f824c5e42 100644 --- a/docs/versioned_docs/version-v0.30.0/noir/concepts/unconstrained.md +++ b/docs/versioned_docs/version-v0.30.0/noir/concepts/unconstrained.md @@ -96,4 +96,4 @@ Generally we want to use brillig whenever there's something that's easy to verif ## Break and Continue -In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow/#break-and-continue) +In addition to loops over runtime bounds, `break` and `continue` are also available in unconstrained code. See [break and continue](../concepts/control_flow.md#break-and-continue) diff --git a/docs/versioned_docs/version-v0.30.0/noir/modules_packages_crates/dependencies.md b/docs/versioned_docs/version-v0.30.0/noir/modules_packages_crates/dependencies.md index 04c1703d929..2c028d85853 100644 --- a/docs/versioned_docs/version-v0.30.0/noir/modules_packages_crates/dependencies.md +++ b/docs/versioned_docs/version-v0.30.0/noir/modules_packages_crates/dependencies.md @@ -82,14 +82,14 @@ use dep::std::scalar_mul::fixed_base_embedded_curve; ``` Lastly, as demonstrated in the -[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives#examples), you +[elliptic curve example](../standard_library/cryptographic_primitives/ec_primitives.md#examples), you can import multiple items in the same line by enclosing them in curly braces: ```rust use dep::std::ec::tecurve::affine::{Curve, Point}; ``` -We don't have a way to consume libraries from inside a [workspace](./workspaces) as external dependencies right now. +We don't have a way to consume libraries from inside a [workspace](./workspaces.md) as external dependencies right now. Inside a workspace, these are consumed as `{ path = "../to_lib" }` dependencies in Nargo.toml. diff --git a/docs/versioned_docs/version-v0.30.0/noir/standard_library/black_box_fns.md b/docs/versioned_docs/version-v0.30.0/noir/standard_library/black_box_fns.md index eeead580969..d5694250f05 100644 --- a/docs/versioned_docs/version-v0.30.0/noir/standard_library/black_box_fns.md +++ b/docs/versioned_docs/version-v0.30.0/noir/standard_library/black_box_fns.md @@ -25,7 +25,7 @@ Here is a list of the current black box functions: - XOR - RANGE - [Keccak256](./cryptographic_primitives/hashes.mdx#keccak256) -- [Recursive proof verification](./recursion) +- [Recursive proof verification](./recursion.md) Most black box functions are included as part of the Noir standard library, however `AND`, `XOR` and `RANGE` are used as part of the Noir language syntax. For instance, using the bitwise operator `&` will invoke the `AND` black box function. diff --git a/docs/versioned_docs/version-v0.30.0/noir/standard_library/recursion.md b/docs/versioned_docs/version-v0.30.0/noir/standard_library/recursion.md index a93894043dc..f33c285cf4e 100644 --- a/docs/versioned_docs/version-v0.30.0/noir/standard_library/recursion.md +++ b/docs/versioned_docs/version-v0.30.0/noir/standard_library/recursion.md @@ -35,7 +35,7 @@ pub fn verify_proof(verification_key: [Field], proof: [Field], public_inputs: [F :::info -This is a black box function. Read [this section](./black_box_fns) to learn more about black box functions in Noir. +This is a black box function. Read [this section](./black_box_fns.md) to learn more about black box functions in Noir. ::: diff --git a/docs/versioned_docs/version-v0.30.0/tooling/debugger.md b/docs/versioned_docs/version-v0.30.0/tooling/debugger.md index 7c158d949d1..9b7565ba9ff 100644 --- a/docs/versioned_docs/version-v0.30.0/tooling/debugger.md +++ b/docs/versioned_docs/version-v0.30.0/tooling/debugger.md @@ -12,7 +12,7 @@ There are currently two ways of debugging Noir programs: 1. From VS Code, via the [vscode-noir](https://github.com/noir-lang/vscode-noir) extension. You can install it via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=noir-lang.vscode-noir). 2. Via the REPL debugger, which ships with Nargo. -In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/installation) and vscode-noir: +In order to use either version of the debugger, you will need to install recent enough versions of Noir, [Nargo](../getting_started/installation/index.md) and vscode-noir: - Noir & Nargo ≥0.28.0 - Noir's VS Code extension ≥0.0.11 From 87a1d8ebaadb5f0f1ed637b96816f971f946af87 Mon Sep 17 00:00:00 2001 From: jfecher Date: Wed, 12 Jun 2024 09:22:45 -0500 Subject: [PATCH 3/6] fix(elaborator): Fix duplicate methods error (#5225) # Description ## Problem\* Resolves "duplicate method" error when declaring trait methods on different traits with the same method name in the elaborator. ## Summary\* ## Additional Context This was the last error type in aztec packages for the elaborator. ~~After this, there are still some extra unused variable warnings I will fix but the entire crate tests successfully.~~ Nevermind, looks like aztec-nr just naturally has many unused variables ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- compiler/noirc_frontend/src/elaborator/mod.rs | 47 ++++++++++++------- compiler/noirc_frontend/src/node_interner.rs | 1 + .../no_duplicate_methods/Nargo.toml | 6 +++ .../no_duplicate_methods/Prover.toml | 0 .../no_duplicate_methods/src/main.nr | 26 ++++++++++ 5 files changed, 64 insertions(+), 16 deletions(-) create mode 100644 test_programs/compile_success_empty/no_duplicate_methods/Nargo.toml create mode 100644 test_programs/compile_success_empty/no_duplicate_methods/Prover.toml create mode 100644 test_programs/compile_success_empty/no_duplicate_methods/src/main.nr diff --git a/compiler/noirc_frontend/src/elaborator/mod.rs b/compiler/noirc_frontend/src/elaborator/mod.rs index 37ad74b78b0..aee3b5c5807 100644 --- a/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/compiler/noirc_frontend/src/elaborator/mod.rs @@ -232,23 +232,20 @@ impl<'context> Elaborator<'context> { // Must resolve structs before we resolve globals. this.collect_struct_definitions(items.types); - // Bind trait impls to their trait. Collect trait functions, that have a - // default implementation, which hasn't been overridden. - for trait_impl in &mut items.trait_impls { - this.collect_trait_impl(trait_impl); - } - // Before we resolve any function symbols we must go through our impls and // re-collect the methods within into their proper module. This cannot be // done during def collection since we need to be able to resolve the type of // the impl since that determines the module we should collect into. - // - // These are resolved after trait impls so that struct methods are chosen - // over trait methods if there are name conflicts. for ((_self_type, module), impls) in &mut items.impls { this.collect_impls(*module, impls); } + // Bind trait impls to their trait. Collect trait functions, that have a + // default implementation, which hasn't been overridden. + for trait_impl in &mut items.trait_impls { + this.collect_trait_impl(trait_impl); + } + // We must wait to resolve non-literal globals until after we resolve structs since struct // globals will need to reference the struct type they're initialized to to ensure they are valid. while let Some((_, global)) = this.unresolved_globals.pop_first() { @@ -860,9 +857,12 @@ impl<'context> Elaborator<'context> { self.self_type = None; } - fn get_module_mut(&mut self, module: ModuleId) -> &mut ModuleData { + fn get_module_mut( + def_maps: &mut BTreeMap, + module: ModuleId, + ) -> &mut ModuleData { let message = "A crate should always be present for a given crate id"; - &mut self.def_maps.get_mut(&module.krate).expect(message).modules[module.local_id.0] + &mut def_maps.get_mut(&module.krate).expect(message).modules[module.local_id.0] } fn declare_methods_on_struct( @@ -890,7 +890,7 @@ impl<'context> Elaborator<'context> { // Grab the module defined by the struct type. Note that impls are a case // where the module the methods are added to is not the same as the module // they are resolved in. - let module = self.get_module_mut(struct_ref.id.module_id()); + let module = Self::get_module_mut(self.def_maps, struct_ref.id.module_id()); for (_, method_id, method) in &functions.functions { // If this method was already declared, remove it from the module so it cannot @@ -899,22 +899,37 @@ impl<'context> Elaborator<'context> { // If not, that is specialization which is allowed. let name = method.name_ident().clone(); if module.declare_function(name, ItemVisibility::Public, *method_id).is_err() { - module.remove_function(method.name_ident()); + let existing = module.find_func_with_name(method.name_ident()).expect( + "declare_function should only error if there is an existing function", + ); + + // Only remove the existing function from scope if it is from a trait impl as + // well. If it is from a non-trait impl that should override trait impl methods + // anyway so that Foo::bar always resolves to the non-trait impl version. + if self.interner.function_meta(&existing).trait_impl.is_some() { + module.remove_function(method.name_ident()); + } } } - self.declare_struct_methods(self_type, &function_ids); + // Trait impl methods are already declared in NodeInterner::add_trait_implementation + if !is_trait_impl { + self.declare_methods(self_type, &function_ids); + } // We can define methods on primitive types only if we're in the stdlib } else if !is_trait_impl && *self_type != Type::Error { if self.crate_id.is_stdlib() { - self.declare_struct_methods(self_type, &function_ids); + // Trait impl methods are already declared in NodeInterner::add_trait_implementation + if !is_trait_impl { + self.declare_methods(self_type, &function_ids); + } } else { self.push_err(DefCollectorErrorKind::NonStructTypeInImpl { span }); } } } - fn declare_struct_methods(&mut self, self_type: &Type, function_ids: &[FuncId]) { + fn declare_methods(&mut self, self_type: &Type, function_ids: &[FuncId]) { for method_id in function_ids { let method_name = self.interner.function_name(method_id).to_owned(); diff --git a/compiler/noirc_frontend/src/node_interner.rs b/compiler/noirc_frontend/src/node_interner.rs index cef49332b00..6c5f9b6bbcb 100644 --- a/compiler/noirc_frontend/src/node_interner.rs +++ b/compiler/noirc_frontend/src/node_interner.rs @@ -1466,6 +1466,7 @@ impl NodeInterner { force_type_check: bool, ) -> Option { let methods = self.struct_methods.get(&(id, method_name.to_owned())); + // If there is only one method, just return it immediately. // It will still be typechecked later. if !force_type_check { diff --git a/test_programs/compile_success_empty/no_duplicate_methods/Nargo.toml b/test_programs/compile_success_empty/no_duplicate_methods/Nargo.toml new file mode 100644 index 00000000000..2125d475530 --- /dev/null +++ b/test_programs/compile_success_empty/no_duplicate_methods/Nargo.toml @@ -0,0 +1,6 @@ +[package] +name = "no_duplicate_methods" +type = "bin" +authors = [""] + +[dependencies] diff --git a/test_programs/compile_success_empty/no_duplicate_methods/Prover.toml b/test_programs/compile_success_empty/no_duplicate_methods/Prover.toml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test_programs/compile_success_empty/no_duplicate_methods/src/main.nr b/test_programs/compile_success_empty/no_duplicate_methods/src/main.nr new file mode 100644 index 00000000000..2be1d3fa11e --- /dev/null +++ b/test_programs/compile_success_empty/no_duplicate_methods/src/main.nr @@ -0,0 +1,26 @@ +// Test that declaring several methods & trait methods with the same name +// does not trigger a duplicate method error +trait ToField { + fn to_field(self) -> Field; +} +trait ToField2 { + fn to_field(self) -> Field; +} + +struct Foo { x: Field } + +impl ToField for Foo { + fn to_field(self) -> Field { self.x } +} + +impl ToField2 for Foo { + fn to_field(self) -> Field { self.x } +} + +impl Foo { + fn to_field(self) -> Field { + self.x + } +} + +fn main() {} From fde432aacc436b6c57f0d937d7c86836bac0b465 Mon Sep 17 00:00:00 2001 From: jfecher Date: Wed, 12 Jun 2024 10:45:58 -0500 Subject: [PATCH 4/6] fix(elaborator): Fix regression introduced by lazy-global changes (#5223) # Description ## Problem\* Fixes a regression introduced by #5191 ## Summary\* When a global is lazily evaluated, the local module id and file id of the elaborator would change without being reset to the previous value. This lead to scoping issues after the global was evaluated. ## Additional Context I was unable to create a repro for this aside from running `nargo t --use-elaborator` on `aztec-nr` unfortunately. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- compiler/noirc_frontend/src/elaborator/mod.rs | 15 ++++++++++++--- .../noirc_frontend/src/hir/resolution/errors.rs | 2 +- .../noirc_frontend/src/hir/resolution/traits.rs | 1 + compiler/noirc_frontend/src/node_interner.rs | 7 +++++++ 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/compiler/noirc_frontend/src/elaborator/mod.rs b/compiler/noirc_frontend/src/elaborator/mod.rs index aee3b5c5807..3c88a419b99 100644 --- a/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/compiler/noirc_frontend/src/elaborator/mod.rs @@ -308,6 +308,7 @@ impl<'context> Elaborator<'context> { let old_function = std::mem::replace(&mut self.current_function, Some(id)); // Without this, impl methods can accidentally be placed in contracts. See #3254 + let was_in_contract = self.in_contract; if self.self_type.is_some() { self.in_contract = false; } @@ -403,6 +404,7 @@ impl<'context> Elaborator<'context> { self.trait_bounds.clear(); self.in_unconstrained_fn = false; self.interner.update_fn(id, hir_func); + self.in_contract = was_in_contract; self.current_function = old_function; self.current_item = old_item; } @@ -544,6 +546,7 @@ impl<'context> Elaborator<'context> { self.current_function = Some(func_id); // Without this, impl methods can accidentally be placed in contracts. See #3254 + let was_in_contract = self.in_contract; if self.self_type.is_some() { self.in_contract = false; } @@ -659,6 +662,7 @@ impl<'context> Elaborator<'context> { }; self.interner.push_fn_meta(meta, func_id); + self.in_contract = was_in_contract; self.current_function = None; self.scopes.end_function(); self.current_item = None; @@ -1095,6 +1099,7 @@ impl<'context> Elaborator<'context> { // make sure every struct's fields is accurately set. for id in struct_ids { let struct_type = self.interner.get_struct(id); + // Only handle structs without generics as any generics args will be checked // after monomorphization when performing SSA codegen if struct_type.borrow().generics.is_empty() { @@ -1129,8 +1134,8 @@ impl<'context> Elaborator<'context> { } fn elaborate_global(&mut self, global: UnresolvedGlobal) { - self.local_module = global.module_id; - self.file = global.file_id; + let old_module = std::mem::replace(&mut self.local_module, global.module_id); + let old_file = std::mem::replace(&mut self.file, global.file_id); let global_id = global.global_id; self.current_item = Some(DependencyId::Global(global_id)); @@ -1162,6 +1167,8 @@ impl<'context> Elaborator<'context> { // Otherwise we may prematurely default to a Field inside the next function if this // global was unused there, even if it is consistently used as a u8 everywhere else. self.type_variables.clear(); + self.local_module = old_module; + self.file = old_file; } fn elaborate_comptime_global(&mut self, global_id: GlobalId) { @@ -1201,11 +1208,13 @@ impl<'context> Elaborator<'context> { self.local_module = *local_module; for (generics, _, function_set) in function_sets { + self.file = function_set.file_id; self.add_generics(generics); let self_type = self.resolve_type(self_type.clone()); function_set.self_type = Some(self_type.clone()); self.self_type = Some(self_type); self.define_function_metas_for_functions(function_set); + self.self_type = None; self.generics.clear(); } } @@ -1220,10 +1229,10 @@ impl<'context> Elaborator<'context> { let trait_generics = vecmap(&trait_impl.trait_generics, |generic| self.resolve_type(generic.clone())); + trait_impl.resolved_trait_generics = trait_generics; let self_type = self.resolve_type(unresolved_type.clone()); - self.self_type = Some(self_type.clone()); trait_impl.methods.self_type = Some(self_type); diff --git a/compiler/noirc_frontend/src/hir/resolution/errors.rs b/compiler/noirc_frontend/src/hir/resolution/errors.rs index 06f6dda7142..07fbde4db8e 100644 --- a/compiler/noirc_frontend/src/hir/resolution/errors.rs +++ b/compiler/noirc_frontend/src/hir/resolution/errors.rs @@ -319,7 +319,7 @@ impl<'a> From<&'a ResolverError> for Diagnostic { "Usage of the `#[foreign]` or `#[builtin]` function attributes are not allowed outside of the Noir standard library".into(), ident.span(), ), - ResolverError::OracleMarkedAsConstrained { ident } => Diagnostic::simple_error( + ResolverError::OracleMarkedAsConstrained { ident } => Diagnostic::simple_warning( error.to_string(), "Oracle functions must have the `unconstrained` keyword applied".into(), ident.span(), diff --git a/compiler/noirc_frontend/src/hir/resolution/traits.rs b/compiler/noirc_frontend/src/hir/resolution/traits.rs index 3d355fd4447..4c360731711 100644 --- a/compiler/noirc_frontend/src/hir/resolution/traits.rs +++ b/compiler/noirc_frontend/src/hir/resolution/traits.rs @@ -300,6 +300,7 @@ fn collect_trait_impl( let file = def_maps[&crate_id].file_id(trait_impl.module_id); let mut resolver = Resolver::new(interner, &path_resolver, def_maps, file); resolver.add_generics(&trait_impl.generics); + let typ = resolver.resolve_type(unresolved_type); errors.extend(take_errors(trait_impl.file_id, resolver)); diff --git a/compiler/noirc_frontend/src/node_interner.rs b/compiler/noirc_frontend/src/node_interner.rs index 6c5f9b6bbcb..e29c3183993 100644 --- a/compiler/noirc_frontend/src/node_interner.rs +++ b/compiler/noirc_frontend/src/node_interner.rs @@ -1411,6 +1411,13 @@ impl NodeInterner { ) -> Result<(), (Span, FileId)> { self.trait_implementations.insert(impl_id, trait_impl.clone()); + // Avoid adding error types to impls since they'll conflict with every other type. + // We don't need to return an error since we expect an error to already be issued when + // the error type is created. + if object_type == Type::Error { + return Ok(()); + } + // Replace each generic with a fresh type variable let substitutions = impl_generics .into_iter() From 802cd951d90bfdb44e7a6b435ab852369c3a6f8d Mon Sep 17 00:00:00 2001 From: jfecher Date: Wed, 12 Jun 2024 14:34:32 -0500 Subject: [PATCH 5/6] chore: Optimize the elaborator (#5230) # Description ## Problem\* Resolves https://github.com/noir-lang/noir/issues/5194 ## Summary\* Fixes a performance issue where the elaborator was ~2x as slow running `nargo t --use-elaborator` on aztec-nr versus the same tests without the elaborator (4s versus 2s). Found via flamegraph - `self.type_variables` wasn't cleared after each function was elaborated. This Vec is meant to just store type variables local to a function so that we can check if any need type hints after it is done but since it wasn't cleared out, we'd be checking an increasingly large Vec for each function. ## Additional Context With this change the elaborator is slightly faster (but not noticeably) than our current code. 1.9 versus 2.0s average across 10 runs for `nargo t` (with lower std. deviation than our current code as well). ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- compiler/noirc_frontend/src/elaborator/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/noirc_frontend/src/elaborator/mod.rs b/compiler/noirc_frontend/src/elaborator/mod.rs index 3c88a419b99..3b8158667f9 100644 --- a/compiler/noirc_frontend/src/elaborator/mod.rs +++ b/compiler/noirc_frontend/src/elaborator/mod.rs @@ -402,6 +402,7 @@ impl<'context> Elaborator<'context> { meta.function_body = FunctionBody::Resolved; self.trait_bounds.clear(); + self.type_variables.clear(); self.in_unconstrained_fn = false; self.interner.update_fn(id, hir_func); self.in_contract = was_in_contract; From 939bad2b20f0ca884d9a1ccbcee1ba3451621458 Mon Sep 17 00:00:00 2001 From: jfecher Date: Wed, 12 Jun 2024 14:56:47 -0500 Subject: [PATCH 6/6] chore: Parse macros (#5229) # Description ## Problem\* ## Summary\* To try to make it easier to review I'm breaking the parser related changes here out #5203. ## Additional Context It turns out `parser/types.rs` was never in our module tree. I've added it and removed the duplicate parsers for parsing types that were in `parser/parser.rs`. They've had some changes since the copies in `parser/types.rs` were first changed so I've updated those as well. ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[For Experimental Features]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings. --- aztec_macros/src/utils/ast_utils.rs | 7 +- compiler/noirc_frontend/src/ast/expression.rs | 41 ++- compiler/noirc_frontend/src/ast/mod.rs | 12 +- compiler/noirc_frontend/src/ast/statement.rs | 1 + compiler/noirc_frontend/src/debug/mod.rs | 4 + .../src/elaborator/expressions.rs | 2 +- .../src/hir/resolution/resolver.rs | 2 +- compiler/noirc_frontend/src/lexer/lexer.rs | 1 + compiler/noirc_frontend/src/lexer/token.rs | 9 + compiler/noirc_frontend/src/parser/parser.rs | 283 +++--------------- .../noirc_frontend/src/parser/parser/types.rs | 139 ++++++--- tooling/nargo_fmt/src/rewrite/expr.rs | 10 +- tooling/nargo_fmt/tests/expected/let.nr | 4 +- tooling/nargo_fmt/tests/input/let.nr | 4 +- 14 files changed, 220 insertions(+), 299 deletions(-) diff --git a/aztec_macros/src/utils/ast_utils.rs b/aztec_macros/src/utils/ast_utils.rs index 4706be2df25..48b3b25747b 100644 --- a/aztec_macros/src/utils/ast_utils.rs +++ b/aztec_macros/src/utils/ast_utils.rs @@ -47,12 +47,17 @@ pub fn method_call( object, method_name: ident(method_name), arguments, + is_macro_call: false, generics: None, }))) } pub fn call(func: Expression, arguments: Vec) -> Expression { - expression(ExpressionKind::Call(Box::new(CallExpression { func: Box::new(func), arguments }))) + expression(ExpressionKind::Call(Box::new(CallExpression { + func: Box::new(func), + is_macro_call: false, + arguments, + }))) } pub fn pattern(name: &str) -> Pattern { diff --git a/compiler/noirc_frontend/src/ast/expression.rs b/compiler/noirc_frontend/src/ast/expression.rs index 50836add8de..da2d3646b20 100644 --- a/compiler/noirc_frontend/src/ast/expression.rs +++ b/compiler/noirc_frontend/src/ast/expression.rs @@ -33,7 +33,7 @@ pub enum ExpressionKind { Tuple(Vec), Lambda(Box), Parenthesized(Box), - Quote(BlockExpression), + Quote(BlockExpression, Span), Comptime(BlockExpression, Span), // This variant is only emitted when inlining the result of comptime @@ -179,19 +179,21 @@ impl Expression { pub fn member_access_or_method_call( lhs: Expression, - (rhs, args): UnaryRhsMemberAccess, + rhs: UnaryRhsMemberAccess, span: Span, ) -> Expression { - let kind = match args { - None => ExpressionKind::MemberAccess(Box::new(MemberAccessExpression { lhs, rhs })), - Some((generics, arguments)) => { - ExpressionKind::MethodCall(Box::new(MethodCallExpression { - object: lhs, - method_name: rhs, - generics, - arguments, - })) + let kind = match rhs.method_call { + None => { + let rhs = rhs.method_or_field; + ExpressionKind::MemberAccess(Box::new(MemberAccessExpression { lhs, rhs })) } + Some(method_call) => ExpressionKind::MethodCall(Box::new(MethodCallExpression { + object: lhs, + method_name: rhs.method_or_field, + generics: method_call.turbofish, + arguments: method_call.args, + is_macro_call: method_call.macro_call, + })), }; Expression::new(kind, span) } @@ -206,7 +208,12 @@ impl Expression { Expression::new(kind, span) } - pub fn call(lhs: Expression, arguments: Vec, span: Span) -> Expression { + pub fn call( + lhs: Expression, + is_macro_call: bool, + arguments: Vec, + span: Span, + ) -> Expression { // Need to check if lhs is an if expression since users can sequence if expressions // with tuples without calling them. E.g. `if c { t } else { e }(a, b)` is interpreted // as a sequence of { if, tuple } rather than a function call. This behavior matches rust. @@ -224,7 +231,11 @@ impl Expression { ], }) } else { - ExpressionKind::Call(Box::new(CallExpression { func: Box::new(lhs), arguments })) + ExpressionKind::Call(Box::new(CallExpression { + func: Box::new(lhs), + is_macro_call, + arguments, + })) }; Expression::new(kind, span) } @@ -447,6 +458,7 @@ pub enum ArrayLiteral { pub struct CallExpression { pub func: Box, pub arguments: Vec, + pub is_macro_call: bool, } #[derive(Debug, PartialEq, Eq, Clone)] @@ -456,6 +468,7 @@ pub struct MethodCallExpression { /// Method calls have an optional list of generics if the turbofish operator was used pub generics: Option>, pub arguments: Vec, + pub is_macro_call: bool, } #[derive(Debug, PartialEq, Eq, Clone)] @@ -535,7 +548,7 @@ impl Display for ExpressionKind { } Lambda(lambda) => lambda.fmt(f), Parenthesized(sub_expr) => write!(f, "({sub_expr})"), - Quote(block) => write!(f, "quote {block}"), + Quote(block, _) => write!(f, "quote {block}"), Comptime(block, _) => write!(f, "comptime {block}"), Error => write!(f, "Error"), Resolved(_) => write!(f, "?Resolved"), diff --git a/compiler/noirc_frontend/src/ast/mod.rs b/compiler/noirc_frontend/src/ast/mod.rs index bd2b45d9c48..c09ad75818a 100644 --- a/compiler/noirc_frontend/src/ast/mod.rs +++ b/compiler/noirc_frontend/src/ast/mod.rs @@ -134,8 +134,16 @@ pub struct UnresolvedType { } /// Type wrapper for a member access -pub(crate) type UnaryRhsMemberAccess = - (Ident, Option<(Option>, Vec)>); +pub struct UnaryRhsMemberAccess { + pub method_or_field: Ident, + pub method_call: Option, +} + +pub struct UnaryRhsMethodCall { + pub turbofish: Option>, + pub macro_call: bool, + pub args: Vec, +} /// The precursor to TypeExpression, this is the type that the parser allows /// to be used in the length position of an array type. Only constants, variables, diff --git a/compiler/noirc_frontend/src/ast/statement.rs b/compiler/noirc_frontend/src/ast/statement.rs index 9b2c0fbfee8..57a62324064 100644 --- a/compiler/noirc_frontend/src/ast/statement.rs +++ b/compiler/noirc_frontend/src/ast/statement.rs @@ -608,6 +608,7 @@ impl ForRange { object: Expression::new(array_ident.clone(), array_span), method_name: Ident::new("len".to_string(), array_span), generics: None, + is_macro_call: false, arguments: vec![], })); let end_range = Expression::new(end_range, array_span); diff --git a/compiler/noirc_frontend/src/debug/mod.rs b/compiler/noirc_frontend/src/debug/mod.rs index c222e08e77a..f5866f5b756 100644 --- a/compiler/noirc_frontend/src/debug/mod.rs +++ b/compiler/noirc_frontend/src/debug/mod.rs @@ -581,6 +581,7 @@ fn build_assign_var_stmt(var_id: SourceVarId, expr: ast::Expression) -> ast::Sta ), span, }), + is_macro_call: false, arguments: vec![uint_expr(var_id.0 as u128, span), expr], })); ast::Statement { kind: ast::StatementKind::Semi(ast::Expression { kind, span }), span } @@ -599,6 +600,7 @@ fn build_drop_var_stmt(var_id: SourceVarId, span: Span) -> ast::Statement { ), span, }), + is_macro_call: false, arguments: vec![uint_expr(var_id.0 as u128, span)], })); ast::Statement { kind: ast::StatementKind::Semi(ast::Expression { kind, span }), span } @@ -626,6 +628,7 @@ fn build_assign_member_stmt( ), span, }), + is_macro_call: false, arguments: [ vec![uint_expr(var_id.0 as u128, span)], vec![expr.clone()], @@ -649,6 +652,7 @@ fn build_debug_call_stmt(fname: &str, fn_id: DebugFnId, span: Span) -> ast::Stat ), span, }), + is_macro_call: false, arguments: vec![uint_expr(fn_id.0 as u128, span)], })); ast::Statement { kind: ast::StatementKind::Semi(ast::Expression { kind, span }), span } diff --git a/compiler/noirc_frontend/src/elaborator/expressions.rs b/compiler/noirc_frontend/src/elaborator/expressions.rs index a922f552c4b..c1c6945707b 100644 --- a/compiler/noirc_frontend/src/elaborator/expressions.rs +++ b/compiler/noirc_frontend/src/elaborator/expressions.rs @@ -58,7 +58,7 @@ impl<'context> Elaborator<'context> { ExpressionKind::Tuple(tuple) => self.elaborate_tuple(tuple), ExpressionKind::Lambda(lambda) => self.elaborate_lambda(*lambda), ExpressionKind::Parenthesized(expr) => return self.elaborate_expression(*expr), - ExpressionKind::Quote(quote) => self.elaborate_quote(quote), + ExpressionKind::Quote(quote, _) => self.elaborate_quote(quote), ExpressionKind::Comptime(comptime, _) => { return self.elaborate_comptime_block(comptime, expr.span) } diff --git a/compiler/noirc_frontend/src/hir/resolution/resolver.rs b/compiler/noirc_frontend/src/hir/resolution/resolver.rs index 01f58ba4c27..133f971da19 100644 --- a/compiler/noirc_frontend/src/hir/resolution/resolver.rs +++ b/compiler/noirc_frontend/src/hir/resolution/resolver.rs @@ -1641,7 +1641,7 @@ impl<'a> Resolver<'a> { ExpressionKind::Parenthesized(sub_expr) => return self.resolve_expression(*sub_expr), // The quoted expression isn't resolved since we don't want errors if variables aren't defined - ExpressionKind::Quote(block) => HirExpression::Quote(block), + ExpressionKind::Quote(block, _) => HirExpression::Quote(block), ExpressionKind::Comptime(block, _) => { HirExpression::Comptime(self.resolve_block(block)) } diff --git a/compiler/noirc_frontend/src/lexer/lexer.rs b/compiler/noirc_frontend/src/lexer/lexer.rs index 2d1ebf530e3..3d052e22e36 100644 --- a/compiler/noirc_frontend/src/lexer/lexer.rs +++ b/compiler/noirc_frontend/src/lexer/lexer.rs @@ -141,6 +141,7 @@ impl<'a> Lexer<'a> { Some('}') => self.single_char_token(Token::RightBrace), Some('[') => self.single_char_token(Token::LeftBracket), Some(']') => self.single_char_token(Token::RightBracket), + Some('$') => self.single_char_token(Token::DollarSign), Some('"') => self.eat_string_literal(), Some('f') => self.eat_format_string_or_alpha_numeric(), Some('r') => self.eat_raw_string_or_alpha_numeric(), diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index d8555b4fbf7..2199333e90f 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -85,6 +85,8 @@ pub enum BorrowedToken<'input> { Semicolon, /// ! Bang, + /// $ + DollarSign, /// = Assign, #[allow(clippy::upper_case_acronyms)] @@ -179,6 +181,8 @@ pub enum Token { Bang, /// = Assign, + /// $ + DollarSign, #[allow(clippy::upper_case_acronyms)] EOF, @@ -238,6 +242,7 @@ pub fn token_to_borrowed_token(token: &Token) -> BorrowedToken<'_> { Token::Semicolon => BorrowedToken::Semicolon, Token::Assign => BorrowedToken::Assign, Token::Bang => BorrowedToken::Bang, + Token::DollarSign => BorrowedToken::DollarSign, Token::EOF => BorrowedToken::EOF, Token::Invalid(c) => BorrowedToken::Invalid(*c), Token::Whitespace(ref s) => BorrowedToken::Whitespace(s), @@ -349,6 +354,7 @@ impl fmt::Display for Token { Token::Semicolon => write!(f, ";"), Token::Assign => write!(f, "="), Token::Bang => write!(f, "!"), + Token::DollarSign => write!(f, "$"), Token::EOF => write!(f, "end of input"), Token::Invalid(c) => write!(f, "{c}"), Token::Whitespace(ref s) => write!(f, "{s}"), @@ -840,6 +846,7 @@ pub enum Keyword { Crate, Dep, Else, + Expr, Field, Fn, For, @@ -884,6 +891,7 @@ impl fmt::Display for Keyword { Keyword::Crate => write!(f, "crate"), Keyword::Dep => write!(f, "dep"), Keyword::Else => write!(f, "else"), + Keyword::Expr => write!(f, "Expr"), Keyword::Field => write!(f, "Field"), Keyword::Fn => write!(f, "fn"), Keyword::For => write!(f, "for"), @@ -931,6 +939,7 @@ impl Keyword { "crate" => Keyword::Crate, "dep" => Keyword::Dep, "else" => Keyword::Else, + "Expr" => Keyword::Expr, "Field" => Keyword::Field, "fn" => Keyword::Fn, "for" => Keyword::For, diff --git a/compiler/noirc_frontend/src/parser/parser.rs b/compiler/noirc_frontend/src/parser/parser.rs index cabc788e07d..5107e10f4df 100644 --- a/compiler/noirc_frontend/src/parser/parser.rs +++ b/compiler/noirc_frontend/src/parser/parser.rs @@ -24,6 +24,7 @@ //! be limited to cases like the above `fn` example where it is clear we shouldn't back out of the //! current parser to try alternative parsers in a `choice` expression. use self::primitives::{keyword, mutable_reference, variable}; +use self::types::{generic_type_args, maybe_comp_time, parse_type}; use super::{ foldl_with_span, labels::ParsingRuleLabel, parameter_name_recovery, parameter_recovery, @@ -35,8 +36,8 @@ use super::{spanned, Item, ItemKind}; use crate::ast::{ BinaryOp, BinaryOpKind, BlockExpression, ForLoopStatement, ForRange, Ident, IfExpression, InfixExpression, LValue, Literal, ModuleDeclaration, NoirTypeAlias, Param, Path, Pattern, - Recoverable, Statement, TraitBound, TypeImpl, UnaryRhsMemberAccess, UnresolvedTraitConstraint, - UnresolvedTypeExpression, UseTree, UseTreeKind, Visibility, + Recoverable, Statement, TraitBound, TypeImpl, UnaryRhsMemberAccess, UnaryRhsMethodCall, + UnresolvedTraitConstraint, UseTree, UseTreeKind, Visibility, }; use crate::ast::{ Expression, ExpressionKind, LetStatement, StatementKind, UnresolvedType, UnresolvedTypeData, @@ -59,6 +60,7 @@ mod path; mod primitives; mod structs; mod traits; +mod types; // synthesized by LALRPOP lalrpop_mod!(pub noir_parser); @@ -674,41 +676,6 @@ where }) } -fn parse_type<'a>() -> impl NoirParser + 'a { - recursive(parse_type_inner) -} - -fn parse_type_inner<'a>( - recursive_type_parser: impl NoirParser + 'a, -) -> impl NoirParser + 'a { - choice(( - field_type(), - int_type(), - bool_type(), - string_type(), - format_string_type(recursive_type_parser.clone()), - named_type(recursive_type_parser.clone()), - named_trait(recursive_type_parser.clone()), - slice_type(recursive_type_parser.clone()), - array_type(recursive_type_parser.clone()), - parenthesized_type(recursive_type_parser.clone()), - tuple_type(recursive_type_parser.clone()), - function_type(recursive_type_parser.clone()), - mutable_reference_type(recursive_type_parser), - )) -} - -fn parenthesized_type( - recursive_type_parser: impl NoirParser, -) -> impl NoirParser { - recursive_type_parser - .delimited_by(just(Token::LeftParen), just(Token::RightParen)) - .map_with_span(|typ, span| UnresolvedType { - typ: UnresolvedTypeData::Parenthesized(Box::new(typ)), - span: span.into(), - }) -} - fn optional_visibility() -> impl NoirParser { keyword(Keyword::Pub) .or(keyword(Keyword::CallData)) @@ -724,187 +691,6 @@ fn optional_visibility() -> impl NoirParser { }) } -fn maybe_comp_time() -> impl NoirParser { - keyword(Keyword::Comptime).or_not().validate(|opt, span, emit| { - if opt.is_some() { - emit(ParserError::with_reason( - ParserErrorReason::ExperimentalFeature("Comptime values"), - span, - )); - } - opt.is_some() - }) -} - -fn field_type() -> impl NoirParser { - keyword(Keyword::Field) - .map_with_span(|_, span| UnresolvedTypeData::FieldElement.with_span(span)) -} - -fn bool_type() -> impl NoirParser { - keyword(Keyword::Bool).map_with_span(|_, span| UnresolvedTypeData::Bool.with_span(span)) -} - -fn string_type() -> impl NoirParser { - keyword(Keyword::String) - .ignore_then(type_expression().delimited_by(just(Token::Less), just(Token::Greater))) - .map_with_span(|expr, span| UnresolvedTypeData::String(expr).with_span(span)) -} - -fn format_string_type<'a>( - type_parser: impl NoirParser + 'a, -) -> impl NoirParser + 'a { - keyword(Keyword::FormatString) - .ignore_then( - type_expression() - .then_ignore(just(Token::Comma)) - .then(type_parser) - .delimited_by(just(Token::Less), just(Token::Greater)), - ) - .map_with_span(|(size, fields), span| { - UnresolvedTypeData::FormatString(size, Box::new(fields)).with_span(span) - }) -} - -fn int_type() -> impl NoirParser { - filter_map(|span, token: Token| match token { - Token::IntType(int_type) => Ok(int_type), - unexpected => { - Err(ParserError::expected_label(ParsingRuleLabel::IntegerType, unexpected, span)) - } - }) - .validate(|token, span, emit| { - UnresolvedTypeData::from_int_token(token).map(|data| data.with_span(span)).unwrap_or_else( - |err| { - emit(ParserError::with_reason(ParserErrorReason::InvalidBitSize(err.0), span)); - UnresolvedType::error(span) - }, - ) - }) -} - -fn named_type<'a>( - type_parser: impl NoirParser + 'a, -) -> impl NoirParser + 'a { - path().then(generic_type_args(type_parser)).map_with_span(|(path, args), span| { - UnresolvedTypeData::Named(path, args, false).with_span(span) - }) -} - -fn named_trait<'a>( - type_parser: impl NoirParser + 'a, -) -> impl NoirParser + 'a { - keyword(Keyword::Impl).ignore_then(path()).then(generic_type_args(type_parser)).map_with_span( - |(path, args), span| UnresolvedTypeData::TraitAsType(path, args).with_span(span), - ) -} - -fn generic_type_args<'a>( - type_parser: impl NoirParser + 'a, -) -> impl NoirParser> + 'a { - type_parser - .clone() - // Without checking for a terminating ',' or '>' here we may incorrectly - // parse a generic `N * 2` as just the type `N` then fail when there is no - // separator afterward. Failing early here ensures we try the `type_expression` - // parser afterward. - .then_ignore(one_of([Token::Comma, Token::Greater]).rewind()) - .or(type_expression() - .map_with_span(|expr, span| UnresolvedTypeData::Expression(expr).with_span(span))) - .separated_by(just(Token::Comma)) - .allow_trailing() - .at_least(1) - .delimited_by(just(Token::Less), just(Token::Greater)) - .or_not() - .map(Option::unwrap_or_default) -} - -fn array_type<'a>( - type_parser: impl NoirParser + 'a, -) -> impl NoirParser + 'a { - just(Token::LeftBracket) - .ignore_then(type_parser) - .then(just(Token::Semicolon).ignore_then(type_expression())) - .then_ignore(just(Token::RightBracket)) - .map_with_span(|(element_type, size), span| { - UnresolvedTypeData::Array(size, Box::new(element_type)).with_span(span) - }) -} - -fn slice_type(type_parser: impl NoirParser) -> impl NoirParser { - just(Token::LeftBracket) - .ignore_then(type_parser) - .then_ignore(just(Token::RightBracket)) - .map_with_span(|element_type, span| { - UnresolvedTypeData::Slice(Box::new(element_type)).with_span(span) - }) -} - -fn type_expression() -> impl NoirParser { - recursive(|expr| { - expression_with_precedence( - Precedence::lowest_type_precedence(), - expr, - nothing(), - nothing(), - true, - false, - ) - }) - .labelled(ParsingRuleLabel::TypeExpression) - .try_map(UnresolvedTypeExpression::from_expr) -} - -fn tuple_type(type_parser: T) -> impl NoirParser -where - T: NoirParser, -{ - let fields = type_parser.separated_by(just(Token::Comma)).allow_trailing(); - parenthesized(fields).map_with_span(|fields, span| { - if fields.is_empty() { - UnresolvedTypeData::Unit.with_span(span) - } else { - UnresolvedTypeData::Tuple(fields).with_span(span) - } - }) -} - -fn function_type(type_parser: T) -> impl NoirParser -where - T: NoirParser, -{ - let args = parenthesized(type_parser.clone().separated_by(just(Token::Comma)).allow_trailing()); - - let env = just(Token::LeftBracket) - .ignore_then(type_parser.clone()) - .then_ignore(just(Token::RightBracket)) - .or_not() - .map_with_span(|t, span| { - t.unwrap_or_else(|| UnresolvedTypeData::Unit.with_span(Span::empty(span.end()))) - }); - - keyword(Keyword::Fn) - .ignore_then(env) - .then(args) - .then_ignore(just(Token::Arrow)) - .then(type_parser) - .map_with_span(|((env, args), ret), span| { - UnresolvedTypeData::Function(args, Box::new(ret), Box::new(env)).with_span(span) - }) -} - -fn mutable_reference_type(type_parser: T) -> impl NoirParser -where - T: NoirParser, -{ - just(Token::Ampersand) - .ignore_then(keyword(Keyword::Mut)) - .ignore_then(type_parser) - .map_with_span(|element, span| { - UnresolvedTypeData::MutableReference(Box::new(element)).with_span(span) - }) -} - fn expression() -> impl ExprParser { recursive(|expr| { expression_with_precedence( @@ -1073,14 +859,18 @@ where S: NoirParser + 'a, { enum UnaryRhs { - Call(Vec), + Call((Option, Vec)), ArrayIndex(Expression), Cast(UnresolvedType), MemberAccess(UnaryRhsMemberAccess), } // `(arg1, ..., argN)` in `my_func(arg1, ..., argN)` - let call_rhs = parenthesized(expression_list(expr_parser.clone())).map(UnaryRhs::Call); + // Optionally accepts a leading `!` for macro calls. + let call_rhs = just(Token::Bang) + .or_not() + .then(parenthesized(expression_list(expr_parser.clone()))) + .map(UnaryRhs::Call); // `[expr]` in `arr[expr]` let array_rhs = expr_parser @@ -1097,11 +887,23 @@ where // A turbofish operator is optional in a method call to specify generic types let turbofish = primitives::turbofish(type_parser); + // `::!(arg1, .., argN)` with the turbofish and macro portions being optional. + let method_call_rhs = turbofish + .then(just(Token::Bang).or_not()) + .then(parenthesized(expression_list(expr_parser.clone()))) + .map(|((turbofish, macro_call), args)| UnaryRhsMethodCall { + turbofish, + macro_call: macro_call.is_some(), + args, + }); + // `.foo` or `.foo(args)` in `atom.foo` or `atom.foo(args)` let member_rhs = just(Token::Dot) .ignore_then(field_name()) - .then(turbofish.then(parenthesized(expression_list(expr_parser.clone()))).or_not()) - .map(UnaryRhs::MemberAccess) + .then(method_call_rhs.or_not()) + .map(|(method_or_field, method_call)| { + UnaryRhs::MemberAccess(UnaryRhsMemberAccess { method_or_field, method_call }) + }) .labelled(ParsingRuleLabel::FieldAccess); let rhs = choice((call_rhs, array_rhs, cast_rhs, member_rhs)); @@ -1110,7 +912,9 @@ where atom(expr_parser, expr_no_constructors, statement, allow_constructors), rhs, |lhs, rhs, span| match rhs { - UnaryRhs::Call(args) => Expression::call(lhs, args, span), + UnaryRhs::Call((is_macro, args)) => { + Expression::call(lhs, is_macro.is_some(), args, span) + } UnaryRhs::ArrayIndex(index) => Expression::index(lhs, index, span), UnaryRhs::Cast(r#type) => Expression::cast(lhs, r#type, span), UnaryRhs::MemberAccess(field) => { @@ -1272,6 +1076,7 @@ where block(statement.clone()).map(ExpressionKind::Block), comptime_expr(statement.clone()), quote(statement), + unquote(expr_parser.clone()), variable(), literal(), )) @@ -1300,13 +1105,26 @@ fn quote<'a, P>(statement: P) -> impl NoirParser + 'a where P: NoirParser + 'a, { - keyword(Keyword::Quote).ignore_then(block(statement)).validate(|block, span, emit| { - emit(ParserError::with_reason( - ParserErrorReason::ExperimentalFeature("quoted expressions"), - span, - )); - ExpressionKind::Quote(block) - }) + keyword(Keyword::Quote).ignore_then(spanned(block(statement))).validate( + |(block, block_span), span, emit| { + emit(ParserError::with_reason( + ParserErrorReason::ExperimentalFeature("quoted expressions"), + span, + )); + ExpressionKind::Quote(block, block_span) + }, + ) +} + +/// unquote: '$' variable +/// | '$' '(' expression ')' +fn unquote<'a, P>(expr_parser: P) -> impl NoirParser + 'a +where + P: ExprParser + 'a, +{ + let unquote = variable().map_with_span(Expression::new).or(parenthesized(expr_parser)); + // This will be updated to ExpressionKind::Unquote in a later PR + just(Token::DollarSign).ignore_then(unquote).map(|_| ExpressionKind::Error) } fn tuple

(expr_parser: P) -> impl NoirParser @@ -1452,11 +1270,6 @@ mod test { ); } - #[test] - fn parse_type_expression() { - parse_all(type_expression(), vec!["(123)", "123", "(1 + 1)", "(1 + (1))"]); - } - #[test] fn parse_array_sugar() { let valid = vec!["[0;7]", "[(1, 2); 4]", "[0;Four]", "[2;1+3-a]"]; diff --git a/compiler/noirc_frontend/src/parser/parser/types.rs b/compiler/noirc_frontend/src/parser/parser/types.rs index 82dd3dad681..a79a2ef67f2 100644 --- a/compiler/noirc_frontend/src/parser/parser/types.rs +++ b/compiler/noirc_frontend/src/parser/parser/types.rs @@ -1,22 +1,38 @@ use super::{ - expression_with_precedence, keyword, nothing, parenthesized, NoirParser, ParserError, + expression_with_precedence, keyword, nothing, parenthesized, path, NoirParser, ParserError, ParserErrorReason, Precedence, }; -use crate::ast::{UnresolvedType, UnresolvedTypeData}; +use crate::ast::{Recoverable, UnresolvedType, UnresolvedTypeData, UnresolvedTypeExpression}; use crate::parser::labels::ParsingRuleLabel; use crate::token::{Keyword, Token}; -use crate::{Recoverable, UnresolvedTypeExpression}; use chumsky::prelude::*; use noirc_errors::Span; -fn maybe_comp_time() -> impl NoirParser<()> { - keyword(Keyword::Comptime).or_not().validate(|opt, span, emit| { - if opt.is_some() { - emit(ParserError::with_reason(ParserErrorReason::ComptimeDeprecated, span)); - } - }) +pub(super) fn parse_type<'a>() -> impl NoirParser + 'a { + recursive(parse_type_inner) +} + +pub(super) fn parse_type_inner<'a>( + recursive_type_parser: impl NoirParser + 'a, +) -> impl NoirParser + 'a { + choice(( + field_type(), + int_type(), + bool_type(), + string_type(), + expr_type(), + format_string_type(recursive_type_parser.clone()), + named_type(recursive_type_parser.clone()), + named_trait(recursive_type_parser.clone()), + slice_type(recursive_type_parser.clone()), + array_type(recursive_type_parser.clone()), + parenthesized_type(recursive_type_parser.clone()), + tuple_type(recursive_type_parser.clone()), + function_type(recursive_type_parser.clone()), + mutable_reference_type(recursive_type_parser), + )) } pub(super) fn parenthesized_type( @@ -30,29 +46,41 @@ pub(super) fn parenthesized_type( }) } +pub(super) fn maybe_comp_time() -> impl NoirParser { + keyword(Keyword::Comptime).or_not().validate(|opt, span, emit| { + if opt.is_some() { + emit(ParserError::with_reason( + ParserErrorReason::ExperimentalFeature("Comptime values"), + span, + )); + } + opt.is_some() + }) +} + pub(super) fn field_type() -> impl NoirParser { - maybe_comp_time() - .then_ignore(keyword(Keyword::Field)) + keyword(Keyword::Field) .map_with_span(|_, span| UnresolvedTypeData::FieldElement.with_span(span)) } pub(super) fn bool_type() -> impl NoirParser { - maybe_comp_time() - .then_ignore(keyword(Keyword::Bool)) - .map_with_span(|_, span| UnresolvedTypeData::Bool.with_span(span)) + keyword(Keyword::Bool).map_with_span(|_, span| UnresolvedTypeData::Bool.with_span(span)) +} + +/// This is the type `Expr` - the type of a quoted, untyped expression object used for macros +pub(super) fn expr_type() -> impl NoirParser { + keyword(Keyword::Expr).map_with_span(|_, span| UnresolvedTypeData::Code.with_span(span)) } pub(super) fn string_type() -> impl NoirParser { keyword(Keyword::String) - .ignore_then( - type_expression().delimited_by(just(Token::Less), just(Token::Greater)).or_not(), - ) + .ignore_then(type_expression().delimited_by(just(Token::Less), just(Token::Greater))) .map_with_span(|expr, span| UnresolvedTypeData::String(expr).with_span(span)) } -pub(super) fn format_string_type( - type_parser: impl NoirParser, -) -> impl NoirParser { +pub(super) fn format_string_type<'a>( + type_parser: impl NoirParser + 'a, +) -> impl NoirParser + 'a { keyword(Keyword::FormatString) .ignore_then( type_expression() @@ -66,26 +94,61 @@ pub(super) fn format_string_type( } pub(super) fn int_type() -> impl NoirParser { - maybe_comp_time() - .then(filter_map(|span, token: Token| match token { - Token::IntType(int_type) => Ok(int_type), - unexpected => { - Err(ParserError::expected_label(ParsingRuleLabel::IntegerType, unexpected, span)) - } - })) - .validate(|(_, token), span, emit| { - UnresolvedTypeData::from_int_token(token) - .map(|data| data.with_span(span)) - .unwrap_or_else(|err| { - emit(ParserError::with_reason(ParserErrorReason::InvalidBitSize(err.0), span)); - UnresolvedType::error(span) - }) - }) + filter_map(|span, token: Token| match token { + Token::IntType(int_type) => Ok(int_type), + unexpected => { + Err(ParserError::expected_label(ParsingRuleLabel::IntegerType, unexpected, span)) + } + }) + .validate(|token, span, emit| { + UnresolvedTypeData::from_int_token(token).map(|data| data.with_span(span)).unwrap_or_else( + |err| { + emit(ParserError::with_reason(ParserErrorReason::InvalidBitSize(err.0), span)); + UnresolvedType::error(span) + }, + ) + }) } -pub(super) fn array_type( - type_parser: impl NoirParser, -) -> impl NoirParser { +pub(super) fn named_type<'a>( + type_parser: impl NoirParser + 'a, +) -> impl NoirParser + 'a { + path().then(generic_type_args(type_parser)).map_with_span(|(path, args), span| { + UnresolvedTypeData::Named(path, args, false).with_span(span) + }) +} + +pub(super) fn named_trait<'a>( + type_parser: impl NoirParser + 'a, +) -> impl NoirParser + 'a { + keyword(Keyword::Impl).ignore_then(path()).then(generic_type_args(type_parser)).map_with_span( + |(path, args), span| UnresolvedTypeData::TraitAsType(path, args).with_span(span), + ) +} + +pub(super) fn generic_type_args<'a>( + type_parser: impl NoirParser + 'a, +) -> impl NoirParser> + 'a { + type_parser + .clone() + // Without checking for a terminating ',' or '>' here we may incorrectly + // parse a generic `N * 2` as just the type `N` then fail when there is no + // separator afterward. Failing early here ensures we try the `type_expression` + // parser afterward. + .then_ignore(one_of([Token::Comma, Token::Greater]).rewind()) + .or(type_expression() + .map_with_span(|expr, span| UnresolvedTypeData::Expression(expr).with_span(span))) + .separated_by(just(Token::Comma)) + .allow_trailing() + .at_least(1) + .delimited_by(just(Token::Less), just(Token::Greater)) + .or_not() + .map(Option::unwrap_or_default) +} + +pub(super) fn array_type<'a>( + type_parser: impl NoirParser + 'a, +) -> impl NoirParser + 'a { just(Token::LeftBracket) .ignore_then(type_parser) .then(just(Token::Semicolon).ignore_then(type_expression())) diff --git a/tooling/nargo_fmt/src/rewrite/expr.rs b/tooling/nargo_fmt/src/rewrite/expr.rs index 7ff943aea62..1d450bb7e28 100644 --- a/tooling/nargo_fmt/src/rewrite/expr.rs +++ b/tooling/nargo_fmt/src/rewrite/expr.rs @@ -63,7 +63,8 @@ pub(crate) fn rewrite( NewlineMode::IfContainsNewLineAndWidth, ); - format!("{callee}{args}") + let bang = if call_expr.is_macro_call { "!" } else { "" }; + format!("{callee}{bang}{args}") } ExpressionKind::MethodCall(method_call_expr) => { let args_span = visitor.span_before( @@ -85,7 +86,8 @@ pub(crate) fn rewrite( NewlineMode::IfContainsNewLineAndWidth, ); - format!("{object}.{method}{turbofish}{args}") + let bang = if method_call_expr.is_macro_call { "!" } else { "" }; + format!("{object}.{method}{turbofish}{bang}{args}") } ExpressionKind::MemberAccess(member_access_expr) => { let lhs_str = rewrite_sub_expr(visitor, shape, member_access_expr.lhs); @@ -166,7 +168,9 @@ pub(crate) fn rewrite( format!("{path_string}{turbofish}") } ExpressionKind::Lambda(_) => visitor.slice(span).to_string(), - ExpressionKind::Quote(block) => format!("quote {}", rewrite_block(visitor, block, span)), + ExpressionKind::Quote(block, block_span) => { + format!("quote {}", rewrite_block(visitor, block, block_span)) + } ExpressionKind::Comptime(block, block_span) => { format!("comptime {}", rewrite_block(visitor, block, block_span)) } diff --git a/tooling/nargo_fmt/tests/expected/let.nr b/tooling/nargo_fmt/tests/expected/let.nr index c57801155a0..7ff69e74306 100644 --- a/tooling/nargo_fmt/tests/expected/let.nr +++ b/tooling/nargo_fmt/tests/expected/let.nr @@ -44,12 +44,12 @@ fn let_() { } }; - let expr = Expr { + let expr = MyExpr { // A boolean literal (true, false). kind: ExprKind::Bool(true) }; - let expr = Expr { /*A boolean literal (true, false).*/ kind: ExprKind::Bool(true) }; + let expr = MyExpr { /*A boolean literal (true, false).*/ kind: ExprKind::Bool(true) }; let mut V = dep::crate2::MyStruct { Q: x }; let mut V = dep::crate2::MyStruct {}; diff --git a/tooling/nargo_fmt/tests/input/let.nr b/tooling/nargo_fmt/tests/input/let.nr index 67c4ab8bd52..37cdc6655c7 100644 --- a/tooling/nargo_fmt/tests/input/let.nr +++ b/tooling/nargo_fmt/tests/input/let.nr @@ -20,11 +20,11 @@ fn let_() { let person = Person { first_name: "John", last_name: "Doe", home_address: Address { street: "123 Main St", city: "Exampleville", zip_code: "12345", master: Person { first_name: "John", last_name: "Doe", home_address: Address { street: "123 Main St", city: "Exampleville", zip_code: "12345" } } } }; - let expr = Expr {// A boolean literal (true, false). + let expr = MyExpr {// A boolean literal (true, false). kind: ExprKind::Bool(true), }; - let expr = Expr {/*A boolean literal (true, false).*/kind: ExprKind::Bool(true),}; + let expr = MyExpr {/*A boolean literal (true, false).*/kind: ExprKind::Bool(true),}; let mut V = dep::crate2::MyStruct { Q: x }; let mut V = dep::crate2::MyStruct {};