From ca424927ce6c6f3637e938e4df9d052522961f84 Mon Sep 17 00:00:00 2001 From: Michael Benfield Date: Tue, 17 Dec 2024 10:08:46 -0800 Subject: [PATCH] Refactor and improve type checking. Superfluous contants like `ADDRESS_TYPE` in checker.rs are removed, along with some of the `assert_*_type` methods. TypeChecker's implementation of ExpressionVisitor has `Output = Type` rather than `Output = Some(Type)`, and its methods return `Type::Err` on errors rather than None. Many functions in that implementation have a simpler implementation with fewer levels of nesting. Introduced new errors for TypeCheckerError: `type_should_be2` is a replacement for `type_should_be` with a better message. Also various `_mismatch` errors for operators with incorrectly typed operands. Introduce `equal_user` for comparing whether two types are equal as seen by the user - only difference between the older eq_flat is it takes into account current program name when comparing composite types Display CompositeType with program name if present. Parse CompositeType without program name if it's not present. Catch type errors previously not caught: * transition call after async function call (this should eventually be allowed, but it will require changes to codegen) * Abs operand type * Binary operation operand type * Comparing record types with the same name but different programs * Ternary conditional operands not being the same type (Some of these errors were caught before only in the case that their visitor received an expected type as addtional input.) --- compiler/ast/src/functions/core_function.rs | 2 +- compiler/ast/src/struct/mod.rs | 2 +- compiler/ast/src/types/struct_type.rs | 6 +- compiler/ast/src/types/tuple.rs | 3 +- compiler/ast/src/types/type_.rs | 51 +- compiler/parser/src/parser/type_.rs | 2 +- .../passes/src/common/symbol_table/mod.rs | 4 + .../src/symbol_table_creation/creator.rs | 3 +- .../src/type_checking/check_expressions.rs | 1412 ++++++++--------- .../src/type_checking/check_statements.rs | 27 +- compiler/passes/src/type_checking/checker.rs | 883 +++++------ .../errors/type_checker/type_checker_error.rs | 61 +- .../expectations/compiler/address/gt_fail.out | 9 +- .../compiler/address/gte_fail.out | 9 +- .../expectations/compiler/address/lt_fail.out | 9 +- .../compiler/address/lte_fail.out | 9 +- .../array/array_in_composite_data_types.out | 2 +- .../array/array_initialization_fail.out | 4 +- .../compiler/array/array_of_structs.out | 2 +- .../compiler/array/nested_array_sum_fail.out | 7 +- .../expectations/compiler/console/assert.out | 2 +- .../constants/block_height_type_fail.out | 2 +- ...constant_loop_bound_type_mismatch_fail.out | 2 +- .../pedersen128/pedersen128_hash_to_i128.out | 48 +- .../pedersen128/pedersen128_hash_to_i16.out | 48 +- .../pedersen128/pedersen128_hash_to_i32.out | 48 +- .../pedersen128/pedersen128_hash_to_i64.out | 48 +- .../pedersen128/pedersen128_hash_to_i8.out | 48 +- .../pedersen128/pedersen128_hash_to_u128.out | 48 +- .../pedersen128/pedersen128_hash_to_u16.out | 48 +- .../pedersen128/pedersen128_hash_to_u32.out | 48 +- .../pedersen128/pedersen128_hash_to_u64.out | 48 +- .../pedersen128/pedersen128_hash_to_u8.out | 48 +- .../pedersen64/pedersen64_hash_to_i128.out | 48 +- .../pedersen64/pedersen64_hash_to_i16.out | 48 +- .../pedersen64/pedersen64_hash_to_i32.out | 48 +- .../pedersen64/pedersen64_hash_to_i64.out | 48 +- .../pedersen64/pedersen64_hash_to_i8.out | 48 +- .../pedersen64/pedersen64_hash_to_u128.out | 48 +- .../pedersen64/pedersen64_hash_to_u16.out | 48 +- .../pedersen64/pedersen64_hash_to_u32.out | 48 +- .../pedersen64/pedersen64_hash_to_u64.out | 48 +- .../pedersen64/pedersen64_hash_to_u8.out | 48 +- .../pedersen128_commit_to_address.out | 50 +- .../pedersen128_commit_to_field.out | 50 +- .../pedersen128_commit_to_group.out | 50 +- .../pedersen128_hash_to_address.out | 48 +- .../algorithms/pedersen128_hash_to_field.out | 48 +- .../algorithms/pedersen128_hash_to_group.out | 48 +- .../pedersen64_commit_to_address.out | 50 +- .../algorithms/pedersen64_commit_to_field.out | 50 +- .../algorithms/pedersen64_commit_to_group.out | 50 +- .../algorithms/pedersen64_hash_to_address.out | 48 +- .../algorithms/pedersen64_hash_to_field.out | 48 +- .../algorithms/pedersen64_hash_to_group.out | 48 +- .../algorithms/pedersen64_hash_to_scalar.out | 48 +- .../core/algorithms/pedersen_fail.out | 4 +- .../cheatcodes/invalid_cheatcodes_fail.out | 4 +- .../core/cheatcodes/valid_cheatcodes.out | 2 +- .../define_multiple_variables_fail.out | 2 +- .../compiler/examples/auction.out | 2 +- .../compiler/examples/basic_bank.out | 2 +- .../expectations/compiler/examples/board.out | 2 +- .../compiler/examples/lottery.out | 2 +- .../compiler/examples/message.out | 2 +- tests/expectations/compiler/examples/move.out | 2 +- .../compiler/examples/simple_token.out | 2 +- .../compiler/examples/tictactoe.out | 2 +- .../expectations/compiler/examples/token.out | 2 +- tests/expectations/compiler/examples/vote.out | 2 +- .../compiler/expression/cast_coersion.out | 2 +- .../compiler/expression/cast_fail.out | 8 +- .../finalize_incorrect_return_fail.out | 9 +- .../finalize/get_incorrect_type_fail.out | 8 +- .../finalize/get_or_incorrect_type_fail.out | 16 +- .../compiler/finalize/mapping.out | 2 +- .../only_finalize_with_flattening.out | 2 +- .../finalize/rand_incorrect_type_fail.out | 4 +- .../finalize/set_in_an_assignment_fail.out | 2 +- .../finalize/set_incorrect_type_fail.out | 16 +- .../function/dead_code_elimination.out | 2 +- .../compiler/function/flatten_arrays.out | 2 +- .../flatten_inlined_tuples_of_structs.out | 2 +- .../compiler/function/flatten_test.out | 2 +- .../compiler/function/flatten_test_2.out | 4 +- .../function/flatten_tuples_of_structs.out | 2 +- .../function/function_call_tyc_fail.out | 2 +- .../helper_function_with_interface.out | 2 +- .../function/record_in_conditional_return.out | 2 +- .../compiler/function/self_fail.out | 5 - .../function/unknown_parameter_type_fail.out | 2 +- .../futures/async_before_call_fail.out | 11 + .../compiler/futures/future_in_tuple.out | 2 +- .../expectations/compiler/futures/nested.out | 2 +- .../futures/partial_type_specification.out | 2 +- .../compiler/group/mult_by_group_fail.out | 8 +- .../mappings/read_external_mapping.out | 2 +- .../mappings/variable_shadow_mapping_fail.out | 2 +- .../compiler/operations/abs_type_fail.out | 14 + .../compiler/operations/add_type_fail.out | 14 + .../records/duplicate_circuit_name_fail.out | 12 +- .../records/external_nested_record.out | 2 +- .../compiler/records/gates_is_allowed.out | 2 +- .../compiler/records/init_expression.out | 2 +- .../records/init_expression_shorthand.out | 2 +- .../records/init_expression_type_fail.out | 4 +- .../compiler/records/nested_record.out | 2 +- .../records/nested_record_as_function_io.out | 2 +- .../record_declaration_out_of_order.out | 2 +- .../records/record_init_out_of_order.out | 2 +- .../records/record_with_visibility.out | 2 +- .../return_record_instead_of_unit_fail.out | 2 +- .../records/same_name_diff_type_fail.out | 11 + .../expectations/compiler/scalar/div_fail.out | 9 +- .../compiler/scalar/square_root_fail.out | 2 +- .../compiler/signature/signature.out | 2 +- .../signature_with_wrong_types_fail.out | 12 +- .../compiler/statements/assign_ternary.out | 9 +- .../statements/compare_diff_types_fail.out | 31 +- .../compare_invalid_negates_fail.out | 35 - .../statements/non_existant_vars_mul_fail.out | 10 - .../statements/typecheck_statements_fail.out | 97 +- .../unknown_type_in_definition_fail.out | 2 +- .../compiler/structs/external_record.out | 6 +- .../compiler/structs/external_struct.out | 6 +- .../external_struct_in_async_function.out | 2 +- .../expectations/compiler/structs/inline.out | 2 +- .../compiler/structs/inline_undefined.out | 2 +- .../compiler/structs/member_variable.out | 2 +- .../structs/redefine_external_struct.out | 4 +- .../compiler/structs/struct_access_fail.out | 2 +- .../struct_declaration_out_of_order.out | 2 +- .../structs/struct_init_out_of_order.out | 2 +- .../ternary/ternary_mismatch_fail.out | 11 + .../tuple/access_out_of_bounds_fail.out | 5 - .../compiler/tuple/declare_fail.out | 2 +- .../compiler/tuple/return_statement_fail.out | 2 +- .../compiler/tuple/tuple_not_allowed_fail.out | 6 +- .../expectations/compiler/tuple/type_fail.out | 4 +- .../expectations/execution/cast_coersion.out | 2 +- .../flattened_function_and_inline_matches.out | 2 +- tests/expectations/execution/mint.out | 2 +- .../expectations/parser/finalize/finalize.out | 6 +- .../expectations/parser/finalize/mapping.out | 2 +- tests/expectations/parser/program/mapping.out | 2 +- tests/expectations/parser/type_/signature.out | 4 +- .../pedersen128/pedersen128_hash_to_i128.leo | 2 +- .../pedersen128/pedersen128_hash_to_i16.leo | 2 +- .../pedersen128/pedersen128_hash_to_i32.leo | 2 +- .../pedersen128/pedersen128_hash_to_i64.leo | 2 +- .../pedersen128/pedersen128_hash_to_i8.leo | 2 +- .../pedersen128/pedersen128_hash_to_u128.leo | 2 +- .../pedersen128/pedersen128_hash_to_u16.leo | 2 +- .../pedersen128/pedersen128_hash_to_u32.leo | 2 +- .../pedersen128/pedersen128_hash_to_u64.leo | 2 +- .../pedersen128/pedersen128_hash_to_u8.leo | 2 +- .../pedersen64/pedersen64_hash_to_i128.leo | 2 +- .../pedersen64/pedersen64_hash_to_i16.leo | 2 +- .../pedersen64/pedersen64_hash_to_i32.leo | 2 +- .../pedersen64/pedersen64_hash_to_i64.leo | 2 +- .../pedersen64/pedersen64_hash_to_i8.leo | 2 +- .../pedersen64/pedersen64_hash_to_u128.leo | 2 +- .../pedersen64/pedersen64_hash_to_u16.leo | 2 +- .../pedersen64/pedersen64_hash_to_u32.leo | 2 +- .../pedersen64/pedersen64_hash_to_u64.leo | 2 +- .../pedersen64/pedersen64_hash_to_u8.leo | 2 +- .../pedersen128_commit_to_address.leo | 2 +- .../pedersen128_commit_to_field.leo | 2 +- .../pedersen128_commit_to_group.leo | 2 +- .../pedersen128_hash_to_address.leo | 2 +- .../algorithms/pedersen128_hash_to_field.leo | 2 +- .../algorithms/pedersen128_hash_to_group.leo | 2 +- .../pedersen64_commit_to_address.leo | 2 +- .../algorithms/pedersen64_commit_to_field.leo | 2 +- .../algorithms/pedersen64_commit_to_group.leo | 2 +- .../algorithms/pedersen64_hash_to_address.leo | 2 +- .../algorithms/pedersen64_hash_to_field.leo | 2 +- .../algorithms/pedersen64_hash_to_group.leo | 2 +- .../algorithms/pedersen64_hash_to_scalar.leo | 2 +- .../futures/async_before_call_fail.leo | 22 + .../compiler/operations/abs_type_fail.leo | 10 + .../compiler/operations/add_type_fail.leo | 10 + .../records/duplicate_circuit_name_fail.leo | 6 +- .../records/same_name_diff_type_fail.leo | 37 + .../ternary/ternary_mismatch_fail.leo | 10 + 185 files changed, 2463 insertions(+), 2328 deletions(-) create mode 100644 tests/expectations/compiler/futures/async_before_call_fail.out create mode 100644 tests/expectations/compiler/operations/abs_type_fail.out create mode 100644 tests/expectations/compiler/operations/add_type_fail.out create mode 100644 tests/expectations/compiler/records/same_name_diff_type_fail.out create mode 100644 tests/expectations/compiler/ternary/ternary_mismatch_fail.out create mode 100644 tests/tests/compiler/futures/async_before_call_fail.leo create mode 100644 tests/tests/compiler/operations/abs_type_fail.leo create mode 100644 tests/tests/compiler/operations/add_type_fail.leo create mode 100644 tests/tests/compiler/records/same_name_diff_type_fail.leo create mode 100644 tests/tests/compiler/ternary/ternary_mismatch_fail.leo diff --git a/compiler/ast/src/functions/core_function.rs b/compiler/ast/src/functions/core_function.rs index 6af63f333c..2c0d6c3583 100644 --- a/compiler/ast/src/functions/core_function.rs +++ b/compiler/ast/src/functions/core_function.rs @@ -17,7 +17,7 @@ use leo_span::{Symbol, sym}; /// A core instruction that maps directly to an AVM bytecode instruction. -#[derive(Clone, PartialEq, Eq)] +#[derive(Clone, Debug, PartialEq, Eq)] pub enum CoreFunction { BHP256CommitToAddress, BHP256CommitToField, diff --git a/compiler/ast/src/struct/mod.rs b/compiler/ast/src/struct/mod.rs index 61d66f3a37..bd07ee18a9 100644 --- a/compiler/ast/src/struct/mod.rs +++ b/compiler/ast/src/struct/mod.rs @@ -57,7 +57,7 @@ pub struct Composite { impl PartialEq for Composite { fn eq(&self, other: &Self) -> bool { - self.identifier == other.identifier + self.identifier == other.identifier && self.external == other.external } } diff --git a/compiler/ast/src/types/struct_type.rs b/compiler/ast/src/types/struct_type.rs index 2bcb923032..8d8b7c7eb4 100644 --- a/compiler/ast/src/types/struct_type.rs +++ b/compiler/ast/src/types/struct_type.rs @@ -31,6 +31,10 @@ pub struct CompositeType { impl fmt::Display for CompositeType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{id}", id = self.id) + if let Some(program) = self.program { + write!(f, "{}.aleo/{}", program, self.id) + } else { + write!(f, "{}", self.id) + } } } diff --git a/compiler/ast/src/types/tuple.rs b/compiler/ast/src/types/tuple.rs index 78d3d794d8..ad191a8489 100644 --- a/compiler/ast/src/types/tuple.rs +++ b/compiler/ast/src/types/tuple.rs @@ -16,6 +16,7 @@ use crate::Type; +use itertools::Itertools as _; use serde::{Deserialize, Serialize}; use std::fmt; @@ -44,6 +45,6 @@ impl TupleType { impl fmt::Display for TupleType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "({})", self.elements.iter().map(|x| x.to_string()).collect::>().join(",")) + write!(f, "({})", self.elements.iter().format(", ")) } } diff --git a/compiler/ast/src/types/type_.rs b/compiler/ast/src/types/type_.rs index 645e0de9ed..df097420d7 100644 --- a/compiler/ast/src/types/type_.rs +++ b/compiler/ast/src/types/type_.rs @@ -27,7 +27,7 @@ use snarkvm::prelude::{ use std::fmt; /// Explicit type used for defining a variable or expression type -#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +#[derive(Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Type { /// The `address` type. Address, @@ -61,56 +61,11 @@ pub enum Type { Unit, /// Placeholder for a type that could not be resolved or was not well-formed. /// Will eventually lead to a compile error. + #[default] Err, } impl Type { - /// - /// Returns `true` if the self `Type` is equal to the other `Type`. - /// - /// Flattens array syntax: `[[u8; 1]; 2] == [u8; (2, 1)] == true` - /// - pub fn eq_flat(&self, other: &Self) -> bool { - match (self, other) { - (Type::Address, Type::Address) - | (Type::Boolean, Type::Boolean) - | (Type::Field, Type::Field) - | (Type::Group, Type::Group) - | (Type::Scalar, Type::Scalar) - | (Type::Signature, Type::Signature) - | (Type::String, Type::String) - | (Type::Unit, Type::Unit) => true, - (Type::Array(left), Type::Array(right)) => { - left.element_type().eq_flat(right.element_type()) && left.length() == right.length() - } - (Type::Identifier(left), Type::Identifier(right)) => left.name == right.name, - (Type::Integer(left), Type::Integer(right)) => left.eq(right), - (Type::Mapping(left), Type::Mapping(right)) => { - left.key.eq_flat(&right.key) && left.value.eq_flat(&right.value) - } - (Type::Tuple(left), Type::Tuple(right)) if left.length() == right.length() => left - .elements() - .iter() - .zip_eq(right.elements().iter()) - .all(|(left_type, right_type)| left_type.eq_flat(right_type)), - (Type::Composite(left), Type::Composite(right)) => { - left.id.name == right.id.name && left.program == right.program - } - (Type::Future(left), Type::Future(right)) - if left.inputs.len() == right.inputs.len() && left.location.is_some() && right.location.is_some() => - { - left.location == right.location - && left - .inputs() - .iter() - .zip_eq(right.inputs().iter()) - .all(|(left_type, right_type)| left_type.eq_flat(right_type)) - } - _ => false, - } - } - - /// /// Returns `true` if the self `Type` is equal to the other `Type` in all aspects besides composite program of origin. /// /// In the case of futures, it also makes sure that if both are not explicit, they are equal. @@ -194,7 +149,7 @@ impl fmt::Display for Type { Type::Scalar => write!(f, "scalar"), Type::Signature => write!(f, "signature"), Type::String => write!(f, "string"), - Type::Composite(ref struct_type) => write!(f, "{}", struct_type.id.name), + Type::Composite(ref struct_type) => write!(f, "{struct_type}"), Type::Tuple(ref tuple) => write!(f, "{tuple}"), Type::Unit => write!(f, "()"), Type::Err => write!(f, "error"), diff --git a/compiler/parser/src/parser/type_.rs b/compiler/parser/src/parser/type_.rs index d090a3082b..71fc7fa7d4 100644 --- a/compiler/parser/src/parser/type_.rs +++ b/compiler/parser/src/parser/type_.rs @@ -108,7 +108,7 @@ impl ParserContext<'_, N> { } } - Ok((Type::Composite(CompositeType { id: ident, program: self.program_name }), ident.span)) + Ok((Type::Composite(CompositeType { id: ident, program: None }), ident.span)) } else if self.token.token == Token::LeftSquare { // Parse the left bracket. self.expect(&Token::LeftSquare)?; diff --git a/compiler/passes/src/common/symbol_table/mod.rs b/compiler/passes/src/common/symbol_table/mod.rs index acfa2dd01a..16d9bb4817 100644 --- a/compiler/passes/src/common/symbol_table/mod.rs +++ b/compiler/passes/src/common/symbol_table/mod.rs @@ -209,6 +209,10 @@ impl SymbolTable { pub fn lookup_struct(&self, location: Location, main_program: Option) -> Option<&Composite> { if let Some(struct_) = self.structs.get(&location) { return Some(struct_); + } else if location.program.is_none() { + if let Some(struct_) = self.structs.get(&Location::new(main_program, location.name)) { + return Some(struct_); + } } else if location.program == main_program { if let Some(struct_) = self.structs.get(&Location::new(None, location.name)) { return Some(struct_); diff --git a/compiler/passes/src/symbol_table_creation/creator.rs b/compiler/passes/src/symbol_table_creation/creator.rs index af4b77e8d4..86bdffd1d4 100644 --- a/compiler/passes/src/symbol_table_creation/creator.rs +++ b/compiler/passes/src/symbol_table_creation/creator.rs @@ -72,7 +72,8 @@ impl<'a> ProgramVisitor<'a> for SymbolTableCreator<'a> { if !input.is_record && !self.structs.insert(input.name()) { return self.handler.emit_err::(AstError::shadowed_struct(input.name(), input.span).into()); } - if let Err(err) = self.symbol_table.insert_struct(Location::new(input.external, input.name()), input) { + let program_name = input.external.or(self.program_name); + if let Err(err) = self.symbol_table.insert_struct(Location::new(program_name, input.name()), input) { self.handler.emit_err(err); } } diff --git a/compiler/passes/src/type_checking/check_expressions.rs b/compiler/passes/src/type_checking/check_expressions.rs index 29a52a1701..adddaa0534 100644 --- a/compiler/passes/src/type_checking/check_expressions.rs +++ b/compiler/passes/src/type_checking/check_expressions.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::{TypeChecker, VariableSymbol}; +use crate::TypeChecker; use leo_ast::*; use leo_errors::{TypeCheckerError, emitter::Handler}; @@ -24,23 +24,9 @@ use snarkvm::console::network::Network; use itertools::Itertools; -fn return_incorrect_type(t1: Option, t2: Option, expected: &Option) -> Option { - match (t1, t2) { - (Some(t1), Some(t2)) if t1 == t2 => Some(t1), - (Some(t1), Some(t2)) => { - if let Some(expected) = expected { - if &t1 != expected { Some(t1) } else { Some(t2) } - } else { - Some(t1) - } - } - (None, Some(_)) | (Some(_), None) | (None, None) => None, - } -} - impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { type AdditionalInput = Option; - type Output = Option; + type Output = Type; fn visit_expression(&mut self, input: &'a Expression, additional: &Self::AdditionalInput) -> Self::Output { let output = match input { @@ -59,11 +45,8 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { Expression::Unary(unary) => self.visit_unary(unary, additional), Expression::Unit(unit) => self.visit_unit(unit, additional), }; - // If the output type is known, add the expression and its associated type to the symbol table. - if let Some(type_) = &output { - self.type_table.insert(input.id(), type_.clone()); - } - // Return the output type. + // Add the expression and its associated type to the symbol table. + self.type_table.insert(input.id(), output.clone()); output } @@ -71,111 +54,100 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { match input { AccessExpression::Array(access) => { // Check that the expression is an array. - let array_type = self.visit_expression(&access.array, &None); - self.assert_array_type(&array_type, access.array.span()); + let this_type = self.visit_expression(&access.array, &None); + self.assert_array_type(&this_type, access.array.span()); // Check that the index is an integer type. let index_type = self.visit_expression(&access.index, &None); self.assert_int_type(&index_type, access.index.span()); // Get the element type of the array. - let element_type = match array_type { - Some(Type::Array(array_type)) => Some(array_type.element_type().clone()), - _ => None, + let Type::Array(array_type) = this_type else { + // We must have already reported an error above, in our type assertion. + return Type::Err; }; + let element_type = array_type.element_type(); + // If the expected type is known, then check that the element type is the same as the expected type. - if let Some(expected) = expected { - self.assert_type(&element_type, expected, input.span()); - } + self.maybe_assert_type(element_type, expected, input.span()); // Return the element type of the array. - return element_type; + element_type.clone() } AccessExpression::AssociatedFunction(access) => { // Check core struct name and function. - if let Some(core_instruction) = self.get_core_function_call(&access.variant, &access.name) { - // Check that operation is not restricted to finalize blocks. - if self.scope_state.variant != Some(Variant::AsyncFunction) - && core_instruction.is_finalize_command() - { - self.emit_err(TypeCheckerError::operation_must_be_in_finalize_block(input.span())); - } + let Some(core_instruction) = self.get_core_function_call(&access.variant, &access.name) else { + self.emit_err(TypeCheckerError::invalid_core_function_call(access, access.span())); + return Type::Err; + }; + // Check that operation is not restricted to finalize blocks. + if self.scope_state.variant != Some(Variant::AsyncFunction) && core_instruction.is_finalize_command() { + self.emit_err(TypeCheckerError::operation_must_be_in_finalize_block(input.span())); + } - // Get the types of the arguments. - let argument_types = access - .arguments - .iter() - .map(|arg| (self.visit_expression(arg, &None), arg.span())) - .collect::>(); + // Get the types of the arguments. + let argument_types = access + .arguments + .iter() + .map(|arg| (self.visit_expression(arg, &None), arg.span())) + .collect::>(); - // Check that the types of the arguments are valid. - let return_type = - self.check_core_function_call(core_instruction.clone(), &argument_types, input.span()); + // Check that the types of the arguments are valid. + let return_type = + self.check_core_function_call(core_instruction.clone(), &argument_types, input.span()); - // Check return type if the expected type is known. - if let Some(expected) = expected { - self.assert_type(&return_type, expected, input.span()); - } + // Check return type if the expected type is known. + self.maybe_assert_type(&return_type, expected, input.span()); - // Await futures here so that can use the argument variable names to lookup. - if core_instruction == CoreFunction::FutureAwait && access.arguments.len() != 1 { - self.emit_err(TypeCheckerError::can_only_await_one_future_at_a_time(access.span)); - return Some(Type::Unit); - } - return return_type; - } else { - self.emit_err(TypeCheckerError::invalid_core_function_call(access, access.span())); + // Await futures here so that can use the argument variable names to lookup. + if core_instruction == CoreFunction::FutureAwait && access.arguments.len() != 1 { + self.emit_err(TypeCheckerError::can_only_await_one_future_at_a_time(access.span)); } + + return_type } AccessExpression::Tuple(access) => { - if let Some(type_) = self.visit_expression(&access.tuple, &None) { - match type_ { - Type::Tuple(tuple) => { - // Check out of range access. - let index = access.index.value(); - if index > tuple.length() - 1 { - self.emit_err(TypeCheckerError::tuple_out_of_range( - index, - tuple.length(), - access.span(), - )); - } else { - // Lookup type of tuple index. - let actual = tuple.elements().get(index).expect("failed to get tuple index").clone(); - // Emit error for mismatched types. - if let Some(expected) = expected { - self.check_eq_types(&Some(actual.clone()), &Some(expected.clone()), access.span()); - } - // Return type of tuple index. - return Some(actual); - } - } - Type::Future(_) => { - // Get the fully inferred type. - if let Some(Type::Future(inferred_f)) = self.type_table.get(&access.tuple.id()) { - // Make sure in range. - if access.index.value() >= inferred_f.inputs().len() { - self.emit_err(TypeCheckerError::invalid_future_access( - access.index.value(), - inferred_f.inputs().len(), - access.span(), - )); - } else { - // Return the type of the input parameter. - return Some(self.assert_and_return_type( - inferred_f.inputs().get(access.index.value()).unwrap().clone(), - expected, - access.span(), - )); - } - } - } - type_ => { - self.emit_err(TypeCheckerError::type_should_be(type_, "tuple", access.span())); - } + let type_ = self.visit_expression(&access.tuple, &None); + + match type_ { + Type::Err => Type::Err, + Type::Tuple(tuple) => { + // Check out of range access. + let index = access.index.value(); + let Some(actual) = tuple.elements().get(index) else { + self.emit_err(TypeCheckerError::tuple_out_of_range(index, tuple.length(), access.span())); + return Type::Err; + }; + + self.maybe_assert_type(actual, expected, access.span()); + + actual.clone() + } + Type::Future(_) => { + // Get the fully inferred type. + let Some(Type::Future(inferred_f)) = self.type_table.get(&access.tuple.id()) else { + // If a future type was not inferred, we will have already reported an error. + return Type::Err; + }; + + let Some(actual) = inferred_f.inputs().get(access.index.value()) else { + self.emit_err(TypeCheckerError::invalid_future_access( + access.index.value(), + inferred_f.inputs().len(), + access.span(), + )); + return Type::Err; + }; + + self.maybe_assert_type(actual, expected, access.span()); + + actual.clone() + } + type_ => { + self.emit_err(TypeCheckerError::type_should_be2(type_, "a tuple or future", access.span())); + Type::Err } - self.emit_err(TypeCheckerError::invalid_core_function_call(access, access.span())); } } AccessExpression::Member(access) => { @@ -185,15 +157,16 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { sym::caller => { // Check that the operation is not invoked in a `finalize` block. self.check_access_allowed("self.caller", false, access.name.span()); - return Some(Type::Address); + Type::Address } sym::signer => { // Check that operation is not invoked in a `finalize` block. self.check_access_allowed("self.signer", false, access.name.span()); - return Some(Type::Address); + Type::Address } _ => { self.emit_err(TypeCheckerError::invalid_self_access(access.name.span())); + Type::Err } }, // If the access expression is of the form `block.`, then check the is valid. @@ -201,14 +174,13 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { sym::height => { // Check that the operation is invoked in a `finalize` block. self.check_access_allowed("block.height", true, access.name.span()); - return Some(self.assert_and_return_type( - Type::Integer(IntegerType::U32), - expected, - input.span(), - )); + let ty = Type::Integer(IntegerType::U32); + self.maybe_assert_type(&ty, expected, input.span()); + ty } _ => { self.emit_err(TypeCheckerError::invalid_block_access(access.name.span())); + Type::Err } }, // If the access expression is of the form `network.`, then check that the is valid. @@ -216,51 +188,51 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { sym::id => { // Check that the operation is not invoked outside a `finalize` block. self.check_access_allowed("network.id", true, access.name.span()); - return Some(Type::Integer(IntegerType::U16)); + let ty = Type::Integer(IntegerType::U16); + self.maybe_assert_type(&ty, expected, input.span()); + ty } _ => { self.emit_err(TypeCheckerError::invalid_block_access(access.name.span())); + Type::Err } }, _ => { // Check that the type of `inner` in `inner.name` is a struct. match self.visit_expression(&access.inner, &None) { - Some(Type::Composite(struct_)) => { + Type::Err => Type::Err, + Type::Composite(struct_) => { // Retrieve the struct definition associated with `identifier`. - let struct_ = self.lookup_struct(struct_.program, struct_.id.name); - if let Some(struct_) = struct_ { - // Check that `access.name` is a member of the struct. - match struct_.members.iter().find(|member| member.name() == access.name.name) { - // Case where `access.name` is a member of the struct. - Some(Member { type_, .. }) => { - // Check that the type of `access.name` is the same as `expected`. - return Some(self.assert_and_return_type( - type_.clone(), - expected, - access.span(), - )); - } - // Case where `access.name` is not a member of the struct. - None => { - self.emit_err(TypeCheckerError::invalid_struct_variable( - access.name, - &struct_, - access.name.span(), - )); - } - } - } else { + let Some(struct_) = self.lookup_struct(struct_.program, struct_.id.name) else { self.emit_err(TypeCheckerError::undefined_type(&access.inner, access.inner.span())); + return Type::Err; + }; + // Check that `access.name` is a member of the struct. + match struct_.members.iter().find(|member| member.name() == access.name.name) { + // Case where `access.name` is a member of the struct. + Some(Member { type_, .. }) => { + // Check that the type of `access.name` is the same as `expected`. + self.maybe_assert_type(type_, expected, access.span()); + type_.clone() + } + // Case where `access.name` is not a member of the struct. + None => { + self.emit_err(TypeCheckerError::invalid_struct_variable( + access.name, + &struct_, + access.name.span(), + )); + Type::Err + } } } - Some(type_) => { - self.emit_err(TypeCheckerError::type_should_be(type_, "struct", access.inner.span())); - } - None => { - self.emit_err(TypeCheckerError::could_not_determine_type( - &access.inner, + type_ => { + self.emit_err(TypeCheckerError::type_should_be2( + type_, + "a struct or record", access.inner.span(), )); + Type::Err } } } @@ -268,311 +240,266 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { } AccessExpression::AssociatedConstant(access) => { // Check associated constant type and constant name - if let Some(core_constant) = self.get_core_constant(&access.ty, &access.name) { - // Check return type if the expected type is known. - let return_type = Some(core_constant.to_type()); - if let Some(expected) = expected { - self.assert_type(&return_type, expected, input.span()); - } - return return_type; - } else { - self.emit_err(TypeCheckerError::invalid_associated_constant(access, access.span)) - } + let Some(core_constant) = self.get_core_constant(&access.ty, &access.name) else { + self.emit_err(TypeCheckerError::invalid_associated_constant(access, access.span)); + return Type::Err; + }; + let type_ = core_constant.to_type(); + self.maybe_assert_type(&type_, expected, input.span()); + type_ } } - None } fn visit_array(&mut self, input: &'a ArrayExpression, additional: &Self::AdditionalInput) -> Self::Output { - // Get the types of each element expression. - let element_types = - input.elements.iter().map(|element| self.visit_expression(element, &None)).collect::>(); - - // Construct the array type. - let return_type = match element_types.len() { - // The array cannot be empty. - 0 => { - self.emit_err(TypeCheckerError::array_empty(input.span())); - None - } - num_elements => { - if num_elements <= N::MAX_ARRAY_ELEMENTS { - // Check that the element types match. - let mut element_types = element_types.into_iter(); - // Note that this unwrap is safe because we already checked that the array is not empty. - element_types.next().unwrap().map(|first_type| { - // Check that all elements have the same type. - for (element_type, element) in element_types.zip_eq(input.elements.iter().skip(1)) { - self.assert_type(&element_type, &first_type, element.span()); - } - // Return the array type. - Type::Array(ArrayType::new(first_type, NonNegativeNumber::from(input.elements.len()))) - }) - } else { - // The array cannot have more than `MAX_ARRAY_ELEMENTS` elements. - self.emit_err(TypeCheckerError::array_too_large(num_elements, N::MAX_ARRAY_ELEMENTS, input.span())); - None - } + if input.elements.is_empty() { + self.emit_err(TypeCheckerError::array_empty(input.span())); + return Type::Err; + } + + let element_type = self.visit_expression(&input.elements[0], &None); + + if input.elements.len() > N::MAX_ARRAY_ELEMENTS { + self.emit_err(TypeCheckerError::array_too_large(input.elements.len(), N::MAX_ARRAY_ELEMENTS, input.span())); + } + + if element_type == Type::Err { + return Type::Err; + } + + for expression in input.elements[1..].iter() { + let next_type = self.visit_expression(expression, &None); + + if next_type == Type::Err { + return Type::Err; } - }; - // If the expected type is known, then check that the array type is the same as the expected type. - if let Some(expected) = additional { - self.assert_type(&return_type, expected, input.span()); + self.assert_type(&next_type, &element_type, expression.span()); } - // Return the array type. - return_type + let type_ = Type::Array(ArrayType::new(element_type, NonNegativeNumber::from(input.elements.len()))); + + self.maybe_assert_type(&type_, additional, input.span()); + + type_ } fn visit_binary(&mut self, input: &'a BinaryExpression, destination: &Self::AdditionalInput) -> Self::Output { + let assert_same_type = |slf: &Self, t1: &Type, t2: &Type| -> Type { + if t1 == &Type::Err || t2 == &Type::Err { + Type::Err + } else if !slf.eq_user(t1, t2) { + slf.emit_err(TypeCheckerError::operation_types_mismatch(input.op, t1, t2, input.span())); + Type::Err + } else { + t1.clone() + } + }; + match input.op { BinaryOperation::And | BinaryOperation::Or | BinaryOperation::Nand | BinaryOperation::Nor => { - // Only boolean types. - self.assert_bool_type(destination, input.span()); - let t1 = self.visit_expression(&input.left, destination); - let t2 = self.visit_expression(&input.right, destination); - - // Check that both operands have the same type. - self.check_eq_types(&t1, &t2, input.span()); - - return_incorrect_type(t1, t2, destination) + self.maybe_assert_type(&Type::Boolean, destination, input.span()); + self.visit_expression(&input.left, &Some(Type::Boolean)); + self.visit_expression(&input.right, &Some(Type::Boolean)); + Type::Boolean } BinaryOperation::BitwiseAnd | BinaryOperation::BitwiseOr | BinaryOperation::Xor => { - // Only boolean or integer types. - self.assert_bool_int_type(destination, input.span()); - let t1 = self.visit_expression(&input.left, destination); - let t2 = self.visit_expression(&input.right, destination); - - // Check that both operands have the same type. - self.check_eq_types(&t1, &t2, input.span()); - - return_incorrect_type(t1, t2, destination) + let t1 = self.visit_expression(&input.left, &None); + self.assert_bool_int_type(&t1, input.left.span()); + let t2 = self.visit_expression(&input.right, &None); + self.assert_bool_int_type(&t2, input.right.span()); + let result_t = assert_same_type(self, &t1, &t2); + self.maybe_assert_type(&result_t, destination, input.span()); + result_t } BinaryOperation::Add => { - // Only field, group, scalar, or integer types. - self.assert_field_group_scalar_int_type(destination, input.span()); - let t1 = self.visit_expression(&input.left, destination); - let t2 = self.visit_expression(&input.right, destination); + let t1 = self.visit_expression(&input.left, &None); + let t2 = self.visit_expression(&input.right, &None); + let assert_add_type = |type_: &Type, span: Span| { + if !matches!(type_, Type::Err | Type::Field | Type::Group | Type::Scalar | Type::Integer(_)) { + self.emit_err(TypeCheckerError::type_should_be2( + type_, + "a field, group, scalar, or integer", + span, + )); + } + }; - // Check that both operands have the same type. - self.check_eq_types(&t1, &t2, input.span()); + assert_add_type(&t1, input.left.span()); + assert_add_type(&t2, input.right.span()); - return_incorrect_type(t1, t2, destination) - } - BinaryOperation::Sub => { - // Only field, group, or integer types. - self.assert_field_group_int_type(destination, input.span()); - let t1 = self.visit_expression(&input.left, destination); - let t2 = self.visit_expression(&input.right, destination); + let result_t = assert_same_type(self, &t1, &t2); - // Check that both operands have the same type. - self.check_eq_types(&t1, &t2, input.span()); + self.maybe_assert_type(&result_t, destination, input.span()); - return_incorrect_type(t1, t2, destination) + result_t } - BinaryOperation::Mul => { - // Operation returns field, group or integer types. - self.assert_field_group_int_type(destination, input.span()); - + BinaryOperation::Sub => { let t1 = self.visit_expression(&input.left, &None); let t2 = self.visit_expression(&input.right, &None); - // Allow group * scalar multiplication. - match (t1, input.left.span(), t2, input.right.span()) { - (Some(Type::Group), _, other, other_span) | (other, other_span, Some(Type::Group), _) => { - // Other type must be scalar. - self.assert_scalar_type(&other, other_span); + self.assert_field_group_int_type(&t1, input.left.span()); + self.assert_field_group_int_type(&t2, input.right.span()); - // Operation returns group. - self.assert_group_type(destination, input.span()); + let result_t = assert_same_type(self, &t1, &t2); - Some(Type::Group) - } - (Some(Type::Field), _, other, other_span) | (other, other_span, Some(Type::Field), _) => { - // Other type must be field. - self.assert_field_type(&other, other_span); + self.maybe_assert_type(&result_t, destination, input.span()); - // Operation returns field. - self.assert_field_type(destination, input.span()); + result_t + } + BinaryOperation::Mul => { + let t1 = self.visit_expression(&input.left, &None); + let t2 = self.visit_expression(&input.right, &None); - Some(Type::Field) + let result_t = match (&t1, &t2) { + (Type::Err, _) | (_, Type::Err) => Type::Err, + (Type::Group, Type::Scalar) | (Type::Scalar, Type::Group) => Type::Group, + (Type::Field, Type::Field) => Type::Field, + (Type::Integer(integer_type1), Type::Integer(integer_type2)) if integer_type1 == integer_type2 => { + t1.clone() } - (Some(Type::Integer(integer_type)), _, other, other_span) - | (other, other_span, Some(Type::Integer(integer_type)), _) => { - // Other type must be the same integer type. - self.assert_type(&other, &Type::Integer(integer_type), other_span); + _ => { + self.emit_err(TypeCheckerError::mul_types_mismatch(t1, t2, input.span())); + Type::Err + } + }; - // Operation returns the same integer type. - self.assert_type(destination, &Type::Integer(integer_type), input.span()); + self.maybe_assert_type(&result_t, destination, input.span()); - Some(Type::Integer(integer_type)) - } - (left_type, left_span, right_type, right_span) => { - let check_type = |type_: Option, expression: &Expression, span: Span| match type_ { - None => { - self.emit_err(TypeCheckerError::could_not_determine_type(expression, span)); - } - Some(type_) => { - self.emit_err(TypeCheckerError::type_should_be( - type_, - "field, group, integer, or scalar", - span, - )); - } - }; - check_type(left_type, &input.left, left_span); - check_type(right_type, &input.right, right_span); - destination.clone() - } - } + result_t } BinaryOperation::Div => { - // Only field or integer types. - self.assert_field_int_type(destination, input.span()); + let t1 = self.visit_expression(&input.left, &None); + let t2 = self.visit_expression(&input.right, &None); + + self.assert_field_int_type(&t1, input.left.span()); + self.assert_field_int_type(&t2, input.right.span()); - let t1 = self.visit_expression(&input.left, destination); - let t2 = self.visit_expression(&input.right, destination); + let result_t = assert_same_type(self, &t1, &t2); - // Check that both operands have the same type. - self.check_eq_types(&t1, &t2, input.span()); + self.maybe_assert_type(&result_t, destination, input.span()); - return_incorrect_type(t1, t2, destination) + result_t } BinaryOperation::Rem | BinaryOperation::RemWrapped => { - // Only integer types. - self.assert_int_type(destination, input.span()); + let t1 = self.visit_expression(&input.left, &None); + let t2 = self.visit_expression(&input.right, &None); - let t1 = self.visit_expression(&input.left, destination); - let t2 = self.visit_expression(&input.right, destination); + self.assert_int_type(&t1, input.left.span()); + self.assert_int_type(&t2, input.right.span()); + + let result_t = assert_same_type(self, &t1, &t2); - // Check that both operands have the same type. - self.check_eq_types(&t1, &t2, input.span()); + self.maybe_assert_type(&result_t, destination, input.span()); - return_incorrect_type(t1, t2, destination) + result_t } BinaryOperation::Mod => { - // Only unsigned integer types. - self.assert_unsigned_int_type(destination, input.span()); + let t1 = self.visit_expression(&input.left, &None); + let t2 = self.visit_expression(&input.right, &None); - let t1 = self.visit_expression(&input.left, destination); - let t2 = self.visit_expression(&input.right, destination); + self.assert_unsigned_type(&t1, input.left.span()); + self.assert_unsigned_type(&t1, input.right.span()); - // Check that both operands have the same type. - self.check_eq_types(&t1, &t2, input.span()); + let result_t = assert_same_type(self, &t1, &t2); - return_incorrect_type(t1, t2, destination) + self.maybe_assert_type(&result_t, destination, input.span()); + + result_t } BinaryOperation::Pow => { - // Operation returns field or integer types. - self.assert_field_int_type(destination, input.span()); - let t1 = self.visit_expression(&input.left, &None); let t2 = self.visit_expression(&input.right, &None); - // Allow field ^ field. - match (t1, t2) { - (Some(Type::Field), right) => { - // Right must be field. - self.assert_field_type(&right, input.right.span()); - - // Operation returns field. - self.assert_field_type(destination, input.span()); - - Some(Type::Field) + let ty = match (&t1, &t2) { + (Type::Err, _) | (_, Type::Err) => Type::Err, + (Type::Field, Type::Field) => Type::Field, + (base @ Type::Integer(_), t2) => { + if !matches!( + t2, + Type::Integer(IntegerType::U8) + | Type::Integer(IntegerType::U16) + | Type::Integer(IntegerType::U32) + ) { + self.emit_err(TypeCheckerError::pow_types_mismatch(base, t2, input.span())); + } + base.clone() } - (left, Some(Type::Field)) => { - // Left must be field. - self.assert_field_type(&left, input.left.span()); - - // Operation returns field. - self.assert_field_type(destination, input.span()); - - Some(Type::Field) + _ => { + self.emit_err(TypeCheckerError::pow_types_mismatch(t1, t2, input.span())); + Type::Err } - (Some(left), right) => { - // Left type is checked to be an integer by above. - // Right type must be magnitude (u8, u16, u32). - self.assert_magnitude_type(&right, input.right.span()); + }; - // Operation returns left type. - self.assert_type(destination, &left, input.span()); + self.maybe_assert_type(&ty, destination, input.span()); - Some(left) - } - (None, right) => { - // Lhs type is checked to be an integer by above. - // Rhs type must be magnitude (u8, u16, u32). - self.assert_magnitude_type(&right, input.right.span()); - destination.clone() - } - } + ty } BinaryOperation::Eq | BinaryOperation::Neq => { - // Assert first and second address, boolean, field, group, scalar, or integer types. let t1 = self.visit_expression(&input.left, &None); let t2 = self.visit_expression(&input.right, &None); - // Check that the types of the operands are equal. - self.check_eq_types(&t1, &t2, input.span()); + let _ = assert_same_type(self, &t1, &t2); - // Operation returns a boolean. - self.assert_bool_type(destination, input.span()); + self.maybe_assert_type(&Type::Boolean, destination, input.span()); - Some(Type::Boolean) + Type::Boolean } BinaryOperation::Lt | BinaryOperation::Gt | BinaryOperation::Lte | BinaryOperation::Gte => { // Assert left and right are equal field, scalar, or integer types. let t1 = self.visit_expression(&input.left, &None); let t2 = self.visit_expression(&input.right, &None); - match (&t1, &t2) { - (Some(Type::Address), _) | (_, Some(Type::Address)) => { - // Emit an error for address comparison. - self.emit_err(TypeCheckerError::compare_address(input.op, input.span())); + let assert_compare_type = |type_: &Type, span: Span| { + if !matches!(type_, Type::Err | Type::Field | Type::Scalar | Type::Integer(_)) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "a field, scalar, or integer", span)); } - (t1, t2) => { - self.assert_field_scalar_int_type(t1, input.left.span()); - self.assert_field_scalar_int_type(t2, input.right.span()); - } - } + }; + + assert_compare_type(&t1, input.left.span()); + assert_compare_type(&t2, input.right.span()); - // Check that the types of the operands are equal. - self.check_eq_types(&t1, &t2, input.span()); + let _ = assert_same_type(self, &t1, &t2); - // Operation returns a boolean. - self.assert_bool_type(destination, input.span()); + self.maybe_assert_type(&Type::Boolean, destination, input.span()); - Some(Type::Boolean) + Type::Boolean } BinaryOperation::AddWrapped | BinaryOperation::SubWrapped | BinaryOperation::DivWrapped | BinaryOperation::MulWrapped => { - // Only integer types. - self.assert_int_type(destination, input.span); - let t1 = self.visit_expression(&input.left, destination); - let t2 = self.visit_expression(&input.right, destination); + let t1 = self.visit_expression(&input.left, &None); + let t2 = self.visit_expression(&input.right, &None); + + self.assert_int_type(&t1, input.left.span()); + self.assert_int_type(&t2, input.right.span()); - // Check that both operands have the same type. - self.check_eq_types(&t1, &t2, input.span()); + let result_t = assert_same_type(self, &t1, &t2); - return_incorrect_type(t1, t2, destination) + self.maybe_assert_type(&result_t, destination, input.span()); + + result_t } BinaryOperation::Shl | BinaryOperation::ShlWrapped | BinaryOperation::Shr | BinaryOperation::ShrWrapped | BinaryOperation::PowWrapped => { - let t1 = self.visit_expression(&input.left, destination); + let t1 = self.visit_expression(&input.left, &None); let t2 = self.visit_expression(&input.right, &None); - // Assert left and destination are equal integer types. self.assert_int_type(&t1, input.left.span()); - self.assert_int_type(destination, input.span); - // Assert right type is a magnitude (u8, u16, u32). - self.assert_magnitude_type(&t2, input.right.span()); + if !matches!( + &t2, + Type::Err + | Type::Integer(IntegerType::U8) + | Type::Integer(IntegerType::U16) + | Type::Integer(IntegerType::U32) + ) { + self.emit_err(TypeCheckerError::shift_type_magnitude(input.op, t2, input.right.span())); + } t1 } @@ -580,310 +507,291 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { } fn visit_call(&mut self, input: &'a CallExpression, expected: &Self::AdditionalInput) -> Self::Output { - match &*input.function { - // Note that the parser guarantees that `input.function` is always an identifier. - Expression::Identifier(ident) => { - // Note: The function symbol lookup is performed outside of the `if let Some(func) ...` block to avoid a RefCell lifetime bug in Rust. - // Do not move it into the `if let Some(func) ...` block or it will keep `self.symbol_table_creation` alive for the entire block and will be very memory inefficient! - let func = - self.symbol_table.borrow().lookup_fn_symbol(Location::new(input.program, ident.name)).cloned(); - if let Some(func) = func { - // Check that the call is valid. - // Note that this unwrap is safe since we always set the variant before traversing the body of the function. - match self.scope_state.variant.unwrap() { - Variant::AsyncFunction | Variant::Function if !matches!(func.variant, Variant::Inline) => { - self.emit_err(TypeCheckerError::can_only_call_inline_function(input.span)) - } - Variant::Transition | Variant::AsyncTransition - if matches!(func.variant, Variant::Transition) - && input.program.unwrap() == self.scope_state.program_name.unwrap() => - { - self.emit_err(TypeCheckerError::cannot_invoke_call_to_local_transition_function(input.span)) - } - _ => {} - } + // Get the function symbol. + let Expression::Identifier(ident) = &*input.function else { + unreachable!("Parsing guarantees that a function name is always an identifier."); + }; + let func = self.symbol_table.borrow().lookup_fn_symbol(Location::new(input.program, ident.name)).cloned(); - // Check that the call is not to an external `inline` function. - if func.variant == Variant::Inline - && input.program.unwrap() != self.scope_state.program_name.unwrap() - { - self.emit_err(TypeCheckerError::cannot_call_external_inline_function(input.span)); - } - // Async functions return a single future. - let mut ret = if func.variant == Variant::AsyncFunction { - // Type check after resolving the input types. - if let Some(Type::Future(_)) = expected { - Type::Future(FutureType::new( - Vec::new(), - Some(Location::new(input.program, ident.name)), - false, - )) - } else { - self.emit_err(TypeCheckerError::return_type_of_finalize_function_is_future(input.span)); - Type::Unit - } - } else if func.variant == Variant::AsyncTransition { - // Fully infer future type. - let future_type = match self - .async_function_input_types - .get(&Location::new(input.program, Symbol::intern(&format!("finalize/{}", ident.name)))) - { - Some(inputs) => Type::Future(FutureType::new( - inputs.clone(), - Some(Location::new(input.program, ident.name)), - true, - )), - None => { - self.emit_err(TypeCheckerError::async_function_not_found(ident.name, input.span)); - return Some(Type::Future(FutureType::new( - Vec::new(), - Some(Location::new(input.program, ident.name)), - false, - ))); - } - }; - let fully_inferred_type = match func.output_type { - Type::Tuple(tup) => Type::Tuple(TupleType::new( - tup.elements() - .iter() - .map(|t| if matches!(t, Type::Future(_)) { future_type.clone() } else { t.clone() }) - .collect::>(), - )), - Type::Future(_) => future_type, - _ => panic!("Invalid output type for async transition."), - }; - self.assert_and_return_type(fully_inferred_type, expected, input.span()) - } else { - self.assert_and_return_type(func.output_type, expected, input.span()) - }; - - // Check number of function arguments. - if func.input.len() != input.arguments.len() { - self.emit_err(TypeCheckerError::incorrect_num_args_to_call( - func.input.len(), - input.arguments.len(), - input.span(), - )); - } + let Some(func) = func else { + self.emit_err(TypeCheckerError::unknown_sym("function", ident.name, ident.span())); + return Type::Err; + }; - // Check function argument types. - self.scope_state.is_call = true; - let (mut input_futures, mut inferred_finalize_inputs) = (Vec::new(), Vec::new()); - for (expected, argument) in func.input.iter().zip(input.arguments.iter()) { - // Get the type of the expression. If the type is not known, do not attempt to attempt any further inference. - let ty = self.visit_expression(argument, &Some(expected.type_().clone()))?; - // Extract information about futures that are being consumed. - if func.variant == Variant::AsyncFunction && matches!(expected.type_(), Type::Future(_)) { - // Consume the future. - let option_name = match argument { - Expression::Identifier(id) => Some(id.name), - Expression::Access(AccessExpression::Tuple(tuple_access)) => { - if let Expression::Identifier(id) = &*tuple_access.tuple { - Some(id.name) - } else { - None - } - } - _ => None, - }; + // Check that the call is valid. + // We always set the variant before entering the body of a function, so this unwrap works. + match self.scope_state.variant.unwrap() { + Variant::AsyncFunction | Variant::Function if !matches!(func.variant, Variant::Inline) => { + self.emit_err(TypeCheckerError::can_only_call_inline_function(input.span)) + } + Variant::Transition | Variant::AsyncTransition + if matches!(func.variant, Variant::Transition) + && input.program.unwrap() == self.scope_state.program_name.unwrap() => + { + self.emit_err(TypeCheckerError::cannot_invoke_call_to_local_transition_function(input.span)) + } + _ => {} + } - if let Some(name) = option_name { - match self.scope_state.futures.shift_remove(&name) { - Some(future) => { - self.scope_state.call_location = Some(future.clone()); - } - None => { - self.emit_err(TypeCheckerError::unknown_future_consumed(name, argument.span())); - } - } - } + // Check that the call is not to an external `inline` function. + if func.variant == Variant::Inline && input.program.unwrap() != self.scope_state.program_name.unwrap() { + self.emit_err(TypeCheckerError::cannot_call_external_inline_function(input.span)); + } - match argument { - Expression::Identifier(_) - | Expression::Call(_) - | Expression::Access(AccessExpression::Tuple(_)) => { - match self.scope_state.call_location.clone() { - Some(location) => { - // Get the external program and function name. - input_futures.push(location); - // Get the full inferred type. - inferred_finalize_inputs.push(ty); - } - None => { - self.emit_err(TypeCheckerError::unknown_future_consumed( - argument, - argument.span(), - )); - } - } - } - _ => { - self.emit_err(TypeCheckerError::unknown_future_consumed( - "unknown", - argument.span(), - )); - } - } - } else { - inferred_finalize_inputs.push(ty); - } - } - self.scope_state.is_call = false; + // Async functions return a single future. + let mut ret = if func.variant == Variant::AsyncFunction { + // Type check after resolving the input types. + if let Some(Type::Future(_)) = expected { + Type::Future(FutureType::new(Vec::new(), Some(Location::new(input.program, ident.name)), false)) + } else { + self.emit_err(TypeCheckerError::return_type_of_finalize_function_is_future(input.span)); + Type::Unit + } + } else if func.variant == Variant::AsyncTransition { + // Fully infer future type. + let Some(inputs) = self + .async_function_input_types + .get(&Location::new(input.program, Symbol::intern(&format!("finalize/{}", ident.name)))) + else { + self.emit_err(TypeCheckerError::async_function_not_found(ident.name, input.span)); + return Type::Future(FutureType::new( + Vec::new(), + Some(Location::new(input.program, ident.name)), + false, + )); + }; - // Add the call to the call graph. - let caller_name = match self.scope_state.function { - None => unreachable!("`self.function` is set every time a function is visited."), - Some(func) => func, - }; + let future_type = + Type::Future(FutureType::new(inputs.clone(), Some(Location::new(input.program, ident.name)), true)); + let fully_inferred_type = match func.output_type { + Type::Tuple(tup) => Type::Tuple(TupleType::new( + tup.elements() + .iter() + .map(|t| if matches!(t, Type::Future(_)) { future_type.clone() } else { t.clone() }) + .collect::>(), + )), + Type::Future(_) => future_type, + _ => panic!("Invalid output type for async transition."), + }; + self.assert_and_return_type(fully_inferred_type, expected, input.span()) + } else { + self.assert_and_return_type(func.output_type, expected, input.span()) + }; - // Don't add external functions to call graph. Since imports are acyclic, these can never produce a cycle. - if input.program.unwrap() == self.scope_state.program_name.unwrap() { - self.call_graph.add_edge(caller_name, ident.name); + // Check number of function arguments. + if func.input.len() != input.arguments.len() { + self.emit_err(TypeCheckerError::incorrect_num_args_to_call( + func.input.len(), + input.arguments.len(), + input.span(), + )); + } + + // Check function argument types. + self.scope_state.is_call = true; + let (mut input_futures, mut inferred_finalize_inputs) = (Vec::new(), Vec::new()); + for (expected, argument) in func.input.iter().zip(input.arguments.iter()) { + // Get the type of the expression. If the type is not known, do not attempt to attempt any further inference. + let ty = self.visit_expression(argument, &Some(expected.type_().clone())); + if ty == Type::Err { + return Type::Err; + } + // Extract information about futures that are being consumed. + if func.variant == Variant::AsyncFunction && matches!(expected.type_(), Type::Future(_)) { + // Consume the future. + let option_name = match argument { + Expression::Identifier(id) => Some(id.name), + Expression::Access(AccessExpression::Tuple(tuple_access)) => { + if let Expression::Identifier(id) = &*tuple_access.tuple { Some(id.name) } else { None } } + _ => None, + }; - // Propagate futures from async functions and transitions. - if func.variant.is_async_function() { - // Cannot have async calls in a conditional block. - if self.scope_state.is_conditional { - self.emit_err(TypeCheckerError::async_call_in_conditional(input.span)); + if let Some(name) = option_name { + match self.scope_state.futures.shift_remove(&name) { + Some(future) => { + self.scope_state.call_location = Some(future.clone()); } - - // Can only call async functions and external async transitions from an async transition body. - if self.scope_state.variant != Some(Variant::AsyncTransition) { - self.emit_err(TypeCheckerError::async_call_can_only_be_done_from_async_transition( - input.span, - )); + None => { + self.emit_err(TypeCheckerError::unknown_future_consumed(name, argument.span())); } + } + } - if func.variant.is_transition() { - // Cannot call an external async transition after having called the async function. - if self.scope_state.has_called_finalize { - self.emit_err(TypeCheckerError::external_transition_call_must_be_before_finalize( - input.span, - )); + match argument { + Expression::Identifier(_) + | Expression::Call(_) + | Expression::Access(AccessExpression::Tuple(_)) => { + match self.scope_state.call_location.clone() { + Some(location) => { + // Get the external program and function name. + input_futures.push(location); + // Get the full inferred type. + inferred_finalize_inputs.push(ty); } - } else if func.variant.is_function() { - // Can only call an async function once in a transition function body. - if self.scope_state.has_called_finalize { - self.emit_err(TypeCheckerError::must_call_async_function_once(input.span)); - } - // Check that all futures consumed. - if !self.scope_state.futures.is_empty() { - self.emit_err(TypeCheckerError::not_all_futures_consumed( - self.scope_state.futures.iter().map(|(f, _)| f.to_string()).join(", "), - input.span, - )); + None => { + self.emit_err(TypeCheckerError::unknown_future_consumed(argument, argument.span())); } - // Add future locations to symbol table. Unwrap safe since insert function into symbol table during previous pass. - let mut st = self.symbol_table.borrow_mut(); - // Insert futures into symbol table. - st.insert_futures(input.program.unwrap(), ident.name, input_futures).unwrap(); - // Link async transition to the async function that finalizes it. - st.attach_finalize( - self.scope_state.location(), - Location::new(self.scope_state.program_name, ident.name), - ) - .unwrap(); - drop(st); - // Create expectation for finalize inputs that will be checked when checking corresponding finalize function signature. - self.async_function_input_types.insert( - Location::new(self.scope_state.program_name, ident.name), - inferred_finalize_inputs.clone(), - ); - - // Set scope state flag. - self.scope_state.has_called_finalize = true; - - // Update ret to reflect fully inferred future type. - ret = Type::Future(FutureType::new( - inferred_finalize_inputs, - Some(Location::new(input.program, ident.name)), - true, - )); - - // Type check in case the expected type is known. - self.assert_and_return_type(ret.clone(), expected, input.span()); } } + _ => { + self.emit_err(TypeCheckerError::unknown_future_consumed("unknown", argument.span())); + } + } + } else { + inferred_finalize_inputs.push(ty); + } + } + self.scope_state.is_call = false; + + // Add the call to the call graph. + let Some(caller_name) = self.scope_state.function else { + unreachable!("`self.function` is set every time a function is visited."); + }; - // Set call location so that definition statement knows where future comes from. - self.scope_state.call_location = Some(Location::new(input.program, ident.name)); + // Don't add external functions to call graph. Since imports are acyclic, these can never produce a cycle. + if input.program.unwrap() == self.scope_state.program_name.unwrap() { + self.call_graph.add_edge(caller_name, ident.name); + } - Some(ret) - } else { - self.emit_err(TypeCheckerError::unknown_sym("function", ident.name, ident.span())); - None - } + if func.variant.is_transition() + && self.scope_state.variant == Some(Variant::AsyncTransition) + && self.scope_state.has_called_finalize + { + // Cannot call an external async transition after having called the async function. + self.emit_err(TypeCheckerError::external_transition_call_must_be_before_finalize(input.span)); + } + + // Propagate futures from async functions and transitions. + if func.variant.is_async_function() { + // Cannot have async calls in a conditional block. + if self.scope_state.is_conditional { + self.emit_err(TypeCheckerError::async_call_in_conditional(input.span)); + } + + // Can only call async functions and external async transitions from an async transition body. + if self.scope_state.variant != Some(Variant::AsyncTransition) { + self.emit_err(TypeCheckerError::async_call_can_only_be_done_from_async_transition(input.span)); + } + + // Can only call an async function once in a transition function body. + if self.scope_state.has_called_finalize { + self.emit_err(TypeCheckerError::must_call_async_function_once(input.span)); + } + // Check that all futures consumed. + if !self.scope_state.futures.is_empty() { + self.emit_err(TypeCheckerError::not_all_futures_consumed( + self.scope_state.futures.iter().map(|(f, _)| f.to_string()).join(", "), + input.span, + )); } - _ => unreachable!("Parsing guarantees that a function name is always an identifier."), + // Add future locations to symbol table. Unwrap safe since insert function into symbol table during previous pass. + let mut st = self.symbol_table.borrow_mut(); + // Insert futures into symbol table. + st.insert_futures(input.program.unwrap(), ident.name, input_futures).unwrap(); + // Link async transition to the async function that finalizes it. + st.attach_finalize(self.scope_state.location(), Location::new(self.scope_state.program_name, ident.name)) + .unwrap(); + drop(st); + // Create expectation for finalize inputs that will be checked when checking corresponding finalize function signature. + self.async_function_input_types + .insert(Location::new(self.scope_state.program_name, ident.name), inferred_finalize_inputs.clone()); + + // Set scope state flag. + self.scope_state.has_called_finalize = true; + + // Update ret to reflect fully inferred future type. + ret = Type::Future(FutureType::new( + inferred_finalize_inputs, + Some(Location::new(input.program, ident.name)), + true, + )); + + // Type check in case the expected type is known. + self.assert_and_return_type(ret.clone(), expected, input.span()); } + + // Set call location so that definition statement knows where future comes from. + self.scope_state.call_location = Some(Location::new(input.program, ident.name)); + + ret } fn visit_cast(&mut self, input: &'a CastExpression, expected: &Self::AdditionalInput) -> Self::Output { - // Check that the target type of the cast expression is a castable type. - self.assert_castable_type(&Some(input.type_.clone()), input.span()); - - // Check that the expression type is a primitive type. let expression_type = self.visit_expression(&input.expression, &None); - self.assert_castable_type(&expression_type, input.expression.span()); - // Check that the expected type matches the target type. - Some(self.assert_and_return_type(input.type_.clone(), expected, input.span())) + let assert_castable_type = |actual: &Type, span: Span| { + if !matches!( + actual, + Type::Integer(_) | Type::Boolean | Type::Field | Type::Group | Type::Scalar | Type::Address | Type::Err, + ) { + self.emit_err(TypeCheckerError::type_should_be2( + actual, + "an integer, bool, field, group, scalar, or address", + span, + )); + } + }; + + assert_castable_type(&input.type_, input.span()); + + assert_castable_type(&expression_type, input.expression.span()); + + self.maybe_assert_type(&input.type_, expected, input.span()); + + input.type_.clone() } fn visit_struct_init(&mut self, input: &'a StructExpression, additional: &Self::AdditionalInput) -> Self::Output { let struct_ = self.lookup_struct(self.scope_state.program_name, input.name.name).clone(); - if let Some(struct_) = struct_ { - // Check struct type name. - let ret = self.check_expected_struct(&struct_, additional, input.name.span()); - - // Check number of struct members. - if struct_.members.len() != input.members.len() { - self.emit_err(TypeCheckerError::incorrect_num_struct_members( - struct_.members.len(), - input.members.len(), - input.span(), - )); - } + let Some(struct_) = struct_ else { + self.emit_err(TypeCheckerError::unknown_sym("struct or record", input.name.name, input.name.span())); + return Type::Err; + }; - // Check struct member types. - struct_.members.iter().for_each(|Member { identifier, type_, .. }| { - // Lookup struct variable name. - if let Some(actual) = input.members.iter().find(|member| member.identifier.name == identifier.name) { - match &actual.expression { - // If `expression` is None, then the member uses the identifier shorthand, e.g. `Foo { a }` - None => self.visit_identifier(&actual.identifier, &Some(type_.clone())), - // Otherwise, visit the associated expression. - Some(expr) => self.visit_expression(expr, &Some(type_.clone())), - }; - } else { - self.emit_err(TypeCheckerError::missing_struct_member( - struct_.identifier, - identifier, - input.span(), - )); - }; - }); + // Note that it is sufficient for the `program` to be `None` as composite types can only be initialized + // in the program in which they are defined. + let type_ = Type::Composite(CompositeType { id: input.name, program: None }); + self.maybe_assert_type(&type_, additional, input.name.span()); + + // Check number of struct members. + if struct_.members.len() != input.members.len() { + self.emit_err(TypeCheckerError::incorrect_num_struct_members( + struct_.members.len(), + input.members.len(), + input.span(), + )); + } - Some(ret) - } else { - self.emit_err(TypeCheckerError::unknown_sym("struct", input.name.name, input.name.span())); - None + for Member { identifier, type_, .. } in struct_.members.iter() { + if let Some(actual) = input.members.iter().find(|member| member.identifier.name == identifier.name) { + match &actual.expression { + // If `expression` is None, then the member uses the identifier shorthand, e.g. `Foo { a }` + None => self.visit_identifier(&actual.identifier, &Some(type_.clone())), + // Otherwise, visit the associated expression. + Some(expr) => self.visit_expression(expr, &Some(type_.clone())), + }; + } else { + self.emit_err(TypeCheckerError::missing_struct_member(struct_.identifier, identifier, input.span())); + }; } + + type_ } // We do not want to panic on `ErrExpression`s in order to propagate as many errors as possible. fn visit_err(&mut self, _input: &'a ErrExpression, _additional: &Self::AdditionalInput) -> Self::Output { - Default::default() + Type::Err } fn visit_identifier(&mut self, input: &'a Identifier, expected: &Self::AdditionalInput) -> Self::Output { let var = self.symbol_table.borrow().lookup_variable(Location::new(None, input.name)).cloned(); if let Some(var) = &var { - Some(self.assert_and_return_type(var.type_.clone(), expected, input.span())) + self.maybe_assert_type(&var.type_, expected, input.span()); + var.type_.clone() } else { self.emit_err(TypeCheckerError::unknown_sym("variable", input.name, input.span())); - None + Type::Err } } @@ -895,73 +803,76 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { } } - Some(match input { - Literal::Address(_, _, _) => self.assert_and_return_type(Type::Address, expected, input.span()), - Literal::Boolean(_, _, _) => self.assert_and_return_type(Type::Boolean, expected, input.span()), - Literal::Field(_, _, _) => self.assert_and_return_type(Type::Field, expected, input.span()), - Literal::Integer(integer_type, string, _, _) => match integer_type { - IntegerType::U8 => { - parse_integer_literal::(self.handler, string, input.span(), "u8"); - self.assert_and_return_type(Type::Integer(IntegerType::U8), expected, input.span()) - } - IntegerType::U16 => { - parse_integer_literal::(self.handler, string, input.span(), "u16"); - self.assert_and_return_type(Type::Integer(IntegerType::U16), expected, input.span()) - } - IntegerType::U32 => { - parse_integer_literal::(self.handler, string, input.span(), "u32"); - self.assert_and_return_type(Type::Integer(IntegerType::U32), expected, input.span()) - } - IntegerType::U64 => { - parse_integer_literal::(self.handler, string, input.span(), "u64"); - self.assert_and_return_type(Type::Integer(IntegerType::U64), expected, input.span()) - } - IntegerType::U128 => { - parse_integer_literal::(self.handler, string, input.span(), "u128"); - self.assert_and_return_type(Type::Integer(IntegerType::U128), expected, input.span()) - } - IntegerType::I8 => { - parse_integer_literal::(self.handler, string, input.span(), "i8"); - self.assert_and_return_type(Type::Integer(IntegerType::I8), expected, input.span()) - } - IntegerType::I16 => { - parse_integer_literal::(self.handler, string, input.span(), "i16"); - self.assert_and_return_type(Type::Integer(IntegerType::I16), expected, input.span()) - } - IntegerType::I32 => { - parse_integer_literal::(self.handler, string, input.span(), "i32"); - self.assert_and_return_type(Type::Integer(IntegerType::I32), expected, input.span()) - } - IntegerType::I64 => { - parse_integer_literal::(self.handler, string, input.span(), "i64"); - self.assert_and_return_type(Type::Integer(IntegerType::I64), expected, input.span()) - } - IntegerType::I128 => { - parse_integer_literal::(self.handler, string, input.span(), "i128"); - self.assert_and_return_type(Type::Integer(IntegerType::I128), expected, input.span()) - } - }, - Literal::Group(_) => self.assert_and_return_type(Type::Group, expected, input.span()), - Literal::Scalar(_, _, _) => self.assert_and_return_type(Type::Scalar, expected, input.span()), - Literal::String(_, _, _) => { + let type_ = match input { + Literal::Address(_, _, _) => Type::Address, + Literal::Boolean(_, _, _) => Type::Boolean, + Literal::Field(_, _, _) => Type::Field, + Literal::Integer(IntegerType::U8, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "u8"); + Type::Integer(IntegerType::U8) + } + Literal::Integer(IntegerType::U16, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "u16"); + Type::Integer(IntegerType::U16) + } + Literal::Integer(IntegerType::U32, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "u32"); + Type::Integer(IntegerType::U32) + } + Literal::Integer(IntegerType::U64, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "u64"); + Type::Integer(IntegerType::U64) + } + Literal::Integer(IntegerType::U128, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "u128"); + Type::Integer(IntegerType::U128) + } + Literal::Integer(IntegerType::I8, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "i8"); + Type::Integer(IntegerType::I8) + } + Literal::Integer(IntegerType::I16, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "i16"); + Type::Integer(IntegerType::I16) + } + Literal::Integer(IntegerType::I32, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "i32"); + Type::Integer(IntegerType::I32) + } + Literal::Integer(IntegerType::I64, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "i64"); + Type::Integer(IntegerType::I64) + } + Literal::Integer(IntegerType::I128, string, ..) => { + parse_integer_literal::(self.handler, string, input.span(), "i128"); + Type::Integer(IntegerType::I128) + } + Literal::Group(_) => Type::Group, + Literal::Scalar(..) => Type::Scalar, + Literal::String(..) => { self.emit_err(TypeCheckerError::strings_are_not_supported(input.span())); - self.assert_and_return_type(Type::String, expected, input.span()) + Type::String } - }) + }; + + self.maybe_assert_type(&type_, expected, input.span()); + + type_ } fn visit_locator(&mut self, input: &'a LocatorExpression, expected: &Self::AdditionalInput) -> Self::Output { - // Check that the locator points to a valid resource in the ST. - let loc_: VariableSymbol; - if let Some(var) = - self.symbol_table.borrow().lookup_variable(Location::new(Some(input.program.name.name), input.name)) - { - loc_ = var.clone(); + let maybe_var = self + .symbol_table + .borrow() + .lookup_variable(Location::new(Some(input.program.name.name), input.name)) + .cloned(); + if let Some(var) = maybe_var { + self.maybe_assert_type(&var.type_, expected, input.span()); + var.type_ } else { self.emit_err(TypeCheckerError::unknown_sym("variable", input.name, input.span())); - return None; + Type::Err } - Some(self.assert_and_return_type(loc_.type_.clone(), expected, input.span())) } fn visit_ternary(&mut self, input: &'a TernaryExpression, expected: &Self::AdditionalInput) -> Self::Output { @@ -970,100 +881,127 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> { let t1 = self.visit_expression(&input.if_true, expected); let t2 = self.visit_expression(&input.if_false, expected); - return_incorrect_type(t1, t2, expected) + if t1 == Type::Err || t2 == Type::Err { + Type::Err + } else if !self.eq_user(&t1, &t2) { + self.emit_err(TypeCheckerError::ternary_branch_mismatch(t1, t2, input.span())); + Type::Err + } else { + t1 + } } fn visit_tuple(&mut self, input: &'a TupleExpression, expected: &Self::AdditionalInput) -> Self::Output { - match input.elements.len() { - 0 | 1 => unreachable!("Parsing guarantees that tuple expressions have at least two elements."), - _ => { - // Check the expected tuple types if they are known. - if let Some(Type::Tuple(expected_types)) = expected { - // Check actual length is equal to expected length. - if expected_types.length() != input.elements.len() { - self.emit_err(TypeCheckerError::incorrect_tuple_length( - expected_types.length(), - input.elements.len(), - input.span(), - )); - } - - expected_types.elements().iter().zip(input.elements.iter()).for_each(|(expected, expr)| { - // Check that the component expression is not a tuple. - if matches!(expr, Expression::Tuple(_)) { - self.emit_err(TypeCheckerError::nested_tuple_expression(expr.span())) - } - self.visit_expression(expr, &Some(expected.clone())); - }); + // Check the expected tuple types if they are known. + let Some(Type::Tuple(expected_types)) = expected else { + self.emit_err(TypeCheckerError::invalid_tuple(input.span())); + return Type::Err; + }; - Some(Type::Tuple(expected_types.clone())) - } else { - // Tuples must be explicitly typed. - self.emit_err(TypeCheckerError::invalid_tuple(input.span())); + // Check actual length is equal to expected length. + if expected_types.length() != input.elements.len() { + self.emit_err(TypeCheckerError::incorrect_tuple_length( + expected_types.length(), + input.elements.len(), + input.span(), + )); + } - None - } + for (expr, expected) in input.elements.iter().zip(expected_types.elements().iter()) { + if matches!(expr, Expression::Tuple(_)) { + self.emit_err(TypeCheckerError::nested_tuple_expression(expr.span())) } + + self.visit_expression(expr, &Some(expected.clone())); } + + Type::Tuple(expected_types.clone()) } fn visit_unary(&mut self, input: &'a UnaryExpression, destination: &Self::AdditionalInput) -> Self::Output { - match input.op { + let assert_signed_int = |slf: &mut Self, type_: &Type| { + if !matches!( + type_, + Type::Err + | Type::Integer(IntegerType::I8) + | Type::Integer(IntegerType::I16) + | Type::Integer(IntegerType::I32) + | Type::Integer(IntegerType::I64) + | Type::Integer(IntegerType::I128) + ) { + slf.emit_err(TypeCheckerError::type_should_be2(type_, "a signed integer", input.span())); + } + }; + + let ty = match input.op { UnaryOperation::Abs => { - // Only signed integer types. - self.assert_signed_int_type(destination, input.span()); - self.visit_expression(&input.receiver, destination) + let type_ = self.visit_expression(&input.receiver, &None); + assert_signed_int(self, &type_); + type_ } UnaryOperation::AbsWrapped => { - // Only signed integer types. - self.assert_signed_int_type(destination, input.span()); - self.visit_expression(&input.receiver, destination) + let type_ = self.visit_expression(&input.receiver, &None); + assert_signed_int(self, &type_); + type_ } UnaryOperation::Double => { - // Only field or group types. - self.assert_field_group_type(destination, input.span()); - self.visit_expression(&input.receiver, destination) + let type_ = self.visit_expression(&input.receiver, &None); + if !matches!(&type_, Type::Err | Type::Field | Type::Group) { + self.emit_err(TypeCheckerError::type_should_be2(&type_, "a field or group", input.span())); + } + type_ } UnaryOperation::Inverse => { - // Only field types. - self.assert_field_type(destination, input.span()); - self.visit_expression(&input.receiver, destination) + let type_ = self.visit_expression(&input.receiver, &None); + self.assert_type(&type_, &Type::Field, input.span()); + type_ } UnaryOperation::Negate => { - let type_ = self.visit_expression(&input.receiver, destination); - - // Only field, group, or signed integer types. - self.assert_field_group_signed_int_type(&type_, input.receiver.span()); + let type_ = self.visit_expression(&input.receiver, &None); + if !matches!(&type_, Type::Err | Type::Integer(_) | Type::Group | Type::Field) { + self.emit_err(TypeCheckerError::type_should_be2( + &type_, + "an integer, group, or field", + input.span(), + )); + } type_ } UnaryOperation::Not => { - // Only boolean or integer types. - self.assert_bool_int_type(destination, input.span()); - self.visit_expression(&input.receiver, destination) + let type_ = self.visit_expression(&input.receiver, &None); + if !matches!(&type_, Type::Err | Type::Boolean | Type::Integer(_)) { + self.emit_err(TypeCheckerError::type_should_be2(&type_, "a bool or integer", input.span())); + } + type_ } UnaryOperation::Square => { - // Only field type. - self.assert_field_type(destination, input.span()); - self.visit_expression(&input.receiver, destination) + let type_ = self.visit_expression(&input.receiver, &None); + self.assert_type(&type_, &Type::Field, input.span()); + type_ } UnaryOperation::SquareRoot => { - // Only field type. - self.assert_field_type(destination, input.span()); - self.visit_expression(&input.receiver, destination) + let type_ = self.visit_expression(&input.receiver, &None); + self.assert_type(&type_, &Type::Field, input.span()); + type_ } UnaryOperation::ToXCoordinate | UnaryOperation::ToYCoordinate => { - // Only field type. - self.assert_field_type(destination, input.span()); - self.visit_expression(&input.receiver, &Some(Type::Group)) + let _operand_type = self.visit_expression(&input.receiver, &Some(Type::Group)); + self.maybe_assert_type(&Type::Field, destination, input.span()); + Type::Field } - } + }; + + self.maybe_assert_type(&ty, destination, input.span()); + + ty } - fn visit_unit(&mut self, input: &'a UnitExpression, _additional: &Self::AdditionalInput) -> Self::Output { + fn visit_unit(&mut self, input: &'a UnitExpression, additional: &Self::AdditionalInput) -> Self::Output { // Unit expression are only allowed inside a return statement. if !self.scope_state.is_return { self.emit_err(TypeCheckerError::unit_expression_only_in_return_statements(input.span())); } - Some(Type::Unit) + self.maybe_assert_type(&Type::Unit, additional, input.span()); + Type::Unit } } diff --git a/compiler/passes/src/type_checking/check_statements.rs b/compiler/passes/src/type_checking/check_statements.rs index 6324281f5b..5c36215ba5 100644 --- a/compiler/passes/src/type_checking/check_statements.rs +++ b/compiler/passes/src/type_checking/check_statements.rs @@ -48,15 +48,17 @@ impl<'a, N: Network> StatementVisitor<'a> for TypeChecker<'a, N> { fn visit_assert(&mut self, input: &'a AssertStatement) { match &input.variant { AssertVariant::Assert(expr) => { - let type_ = self.visit_expression(expr, &Some(Type::Boolean)); - self.assert_bool_type(&type_, expr.span()); + let _type = self.visit_expression(expr, &Some(Type::Boolean)); } AssertVariant::AssertEq(left, right) | AssertVariant::AssertNeq(left, right) => { let t1 = self.visit_expression(left, &None); let t2 = self.visit_expression(right, &None); - // Check that the types are equal. - self.check_eq_types(&t1, &t2, input.span()); + if t1 != Type::Err && t2 != Type::Err && !self.eq_user(&t1, &t2) { + let op = + if matches!(input.variant, AssertVariant::AssertEq(..)) { "assert_eq" } else { "assert_neq" }; + self.emit_err(TypeCheckerError::operation_types_mismatch(op, t1, t2, input.span())); + } } } } @@ -246,7 +248,7 @@ impl<'a, N: Network> StatementVisitor<'a> for TypeChecker<'a, N> { // Insert the variables into the symbol table. match &input.place { Expression::Identifier(identifier) => { - self.insert_variable(inferred_type.clone(), identifier, input.type_.clone(), identifier.span) + self.insert_variable(Some(inferred_type.clone()), identifier, input.type_.clone(), identifier.span) } Expression::Tuple(tuple_expression) => { let tuple_type = match &input.type_ { @@ -264,10 +266,10 @@ impl<'a, N: Network> StatementVisitor<'a> for TypeChecker<'a, N> { } for i in 0..tuple_expression.elements.len() { - let inferred = if let Some(Type::Tuple(inferred_tuple)) = &inferred_type { - inferred_tuple.elements().get(i).cloned() + let inferred = if let Type::Tuple(inferred_tuple) = &inferred_type { + inferred_tuple.elements().get(i).cloned().unwrap_or_default() } else { - None + Type::Err }; let expr = &tuple_expression.elements[i]; let identifier = match expr { @@ -277,7 +279,7 @@ impl<'a, N: Network> StatementVisitor<'a> for TypeChecker<'a, N> { .emit_err(TypeCheckerError::lhs_tuple_element_must_be_an_identifier(expr.span())); } }; - self.insert_variable(inferred, identifier, tuple_type.elements()[i].clone(), identifier.span); + self.insert_variable(Some(inferred), identifier, tuple_type.elements()[i].clone(), identifier.span); } } _ => self.emit_err(TypeCheckerError::lhs_must_be_identifier_or_tuple(input.place.span())), @@ -298,8 +300,7 @@ impl<'a, N: Network> StatementVisitor<'a> for TypeChecker<'a, N> { } fn visit_iteration(&mut self, input: &'a IterationStatement) { - let iter_type = &Some(input.type_.clone()); - self.assert_int_type(iter_type, input.variable.span); + self.assert_int_type(&input.type_, input.variable.span); // Create a new scope for the loop body. let scope_index = self.create_child_scope(); @@ -333,7 +334,7 @@ impl<'a, N: Network> StatementVisitor<'a> for TypeChecker<'a, N> { self.exit_scope(scope_index); // Check that the literal is valid. - self.visit_expression(&input.start, iter_type); + self.visit_expression(&input.start, &Some(input.type_.clone())); // If `input.start` is a valid literal, instantiate it as a value. match &input.start { @@ -353,7 +354,7 @@ impl<'a, N: Network> StatementVisitor<'a> for TypeChecker<'a, N> { _ => self.emit_err(TypeCheckerError::loop_bound_must_be_literal_or_const(input.start.span())), } - self.visit_expression(&input.stop, iter_type); + self.visit_expression(&input.stop, &Some(input.type_.clone())); // If `input.stop` is a valid literal, instantiate it as a value. match &input.stop { diff --git a/compiler/passes/src/type_checking/checker.rs b/compiler/passes/src/type_checking/checker.rs index 764f2fa227..b3abf3b267 100644 --- a/compiler/passes/src/type_checking/checker.rs +++ b/compiler/passes/src/type_checking/checker.rs @@ -32,7 +32,7 @@ use snarkvm::console::network::Network; use indexmap::{IndexMap, IndexSet}; use itertools::Itertools; -use std::{cell::RefCell, marker::PhantomData}; +use std::{cell::RefCell, marker::PhantomData, ops::Deref}; pub struct TypeChecker<'a, N: Network> { /// The symbol table for the program. @@ -55,50 +55,6 @@ pub struct TypeChecker<'a, N: Network> { phantom: PhantomData, } -const ADDRESS_TYPE: Type = Type::Address; - -const BOOLEAN_TYPE: Type = Type::Boolean; - -const FIELD_TYPE: Type = Type::Field; - -const GROUP_TYPE: Type = Type::Group; - -const SCALAR_TYPE: Type = Type::Scalar; - -const SIGNATURE_TYPE: Type = Type::Signature; - -const INT_TYPES: [Type; 10] = [ - Type::Integer(IntegerType::I8), - Type::Integer(IntegerType::I16), - Type::Integer(IntegerType::I32), - Type::Integer(IntegerType::I64), - Type::Integer(IntegerType::I128), - Type::Integer(IntegerType::U8), - Type::Integer(IntegerType::U16), - Type::Integer(IntegerType::U32), - Type::Integer(IntegerType::U64), - Type::Integer(IntegerType::U128), -]; - -const SIGNED_INT_TYPES: [Type; 5] = [ - Type::Integer(IntegerType::I8), - Type::Integer(IntegerType::I16), - Type::Integer(IntegerType::I32), - Type::Integer(IntegerType::I64), - Type::Integer(IntegerType::I128), -]; - -const UNSIGNED_INT_TYPES: [Type; 5] = [ - Type::Integer(IntegerType::U8), - Type::Integer(IntegerType::U16), - Type::Integer(IntegerType::U32), - Type::Integer(IntegerType::U64), - Type::Integer(IntegerType::U128), -]; - -const MAGNITUDE_TYPES: [Type; 3] = - [Type::Integer(IntegerType::U8), Type::Integer(IntegerType::U16), Type::Integer(IntegerType::U32)]; - impl<'a, N: Network> TypeChecker<'a, N> { /// Returns a new type checker given a symbol table and error handler. pub fn new(symbol_table: SymbolTable, type_table: &'a TypeTable, handler: &'a Handler) -> Self { @@ -153,15 +109,6 @@ impl<'a, N: Network> TypeChecker<'a, N> { self.handler.emit_warning(warning.into()); } - /// Emits an error to the handler if the given type is invalid. - fn check_type(&self, is_valid: impl Fn(&Type) -> bool, error_string: String, type_: &Option, span: Span) { - if let Some(type_) = type_ { - if !is_valid(type_) { - self.emit_err(TypeCheckerError::expected_one_type_of(error_string, type_, span)); - } - } - } - /// Emits an error if the two given types are not equal. pub(crate) fn check_eq_types(&self, t1: &Option, t2: &Option, span: Span) { match (t1, t2) { @@ -189,168 +136,83 @@ impl<'a, N: Network> TypeChecker<'a, N> { actual } - /// Emits an error to the error handler if the `actual` type is not equal to the `expected` type. - pub(crate) fn assert_type(&mut self, actual: &Option, expected: &Type, span: Span) { - if let Some(actual) = actual { - self.check_eq_types(&Some(actual.clone()), &Some(expected.clone()), span); + pub(crate) fn maybe_assert_type(&mut self, actual: &Type, expected: &Option, span: Span) { + if let Some(expected) = expected { + self.assert_type(actual, expected, span); } } - /// Emits an error to the error handler if the given type is not an address. - pub(crate) fn assert_address_type(&self, type_: &Option, span: Span) { - self.check_type(|type_: &Type| ADDRESS_TYPE.eq(type_), ADDRESS_TYPE.to_string(), type_, span) - } - - /// Emits an error to the handler if the given type is not a boolean. - pub(crate) fn assert_bool_type(&self, type_: &Option, span: Span) { - self.check_type(|type_: &Type| BOOLEAN_TYPE.eq(type_), BOOLEAN_TYPE.to_string(), type_, span) - } - - /// Emits an error to the handler if the given type is not a field. - pub(crate) fn assert_field_type(&self, type_: &Option, span: Span) { - self.check_type(|type_: &Type| FIELD_TYPE.eq(type_), FIELD_TYPE.to_string(), type_, span) - } - - /// Emits an error to the handler if the given type is not a group. - pub(crate) fn assert_group_type(&self, type_: &Option, span: Span) { - self.check_type(|type_: &Type| GROUP_TYPE.eq(type_), GROUP_TYPE.to_string(), type_, span) - } - - /// Emits an error to the handler if the given type is not a scalar. - pub(crate) fn assert_scalar_type(&self, type_: &Option, span: Span) { - self.check_type(|type_: &Type| SCALAR_TYPE.eq(type_), SCALAR_TYPE.to_string(), type_, span) - } - - /// Emits an error to the handler if the given type is not a signature. - pub(crate) fn assert_signature_type(&self, type_: &Option, span: Span) { - self.check_type(|type_: &Type| SIGNATURE_TYPE.eq(type_), SIGNATURE_TYPE.to_string(), type_, span) - } - - /// Emits an error to the handler if the given type is not an integer. - pub(crate) fn assert_int_type(&self, type_: &Option, span: Span) { - self.check_type(|type_: &Type| INT_TYPES.contains(type_), types_to_string(&INT_TYPES), type_, span) - } - - /// Emits an error to the handler if the given type is not a signed integer. - pub(crate) fn assert_signed_int_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| SIGNED_INT_TYPES.contains(type_), - types_to_string(&SIGNED_INT_TYPES), - type_, - span, - ) - } - - /// Emits an error to the handler if the given type is not an unsigned integer. - pub(crate) fn assert_unsigned_int_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| UNSIGNED_INT_TYPES.contains(type_), - types_to_string(&UNSIGNED_INT_TYPES), - type_, - span, - ) - } - - /// Emits an error to the handler if the given type is not a magnitude (u8, u16, u32). - pub(crate) fn assert_magnitude_type(&self, type_: &Option, span: Span) { - self.check_type(|type_: &Type| MAGNITUDE_TYPES.contains(type_), types_to_string(&MAGNITUDE_TYPES), type_, span) - } - - /// Emits an error to the handler if the given type is not a boolean or an integer. - pub(crate) fn assert_bool_int_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| BOOLEAN_TYPE.eq(type_) | INT_TYPES.contains(type_), - format!("{BOOLEAN_TYPE}, {}", types_to_string(&INT_TYPES)), - type_, - span, - ) - } - - /// Emits an error to the handler if the given type is not a field or integer. - pub(crate) fn assert_field_int_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| FIELD_TYPE.eq(type_) | INT_TYPES.contains(type_), - format!("{FIELD_TYPE}, {}", types_to_string(&INT_TYPES)), - type_, - span, - ) - } - - /// Emits an error to the handler if the given type is not a field or group. - pub(crate) fn assert_field_group_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| FIELD_TYPE.eq(type_) | GROUP_TYPE.eq(type_), - format!("{FIELD_TYPE}, {GROUP_TYPE}"), - type_, - span, - ) + pub(crate) fn assert_type(&mut self, actual: &Type, expected: &Type, span: Span) { + if actual != &Type::Err && !self.eq_user(actual, expected) { + // If `actual` is Err, we will have already reported an error. + self.emit_err(TypeCheckerError::type_should_be2(actual, format!("type `{expected}`"), span)); + } } - /// Emits an error to the handler if the given type is not a field, group, or integer. - pub(crate) fn assert_field_group_int_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| FIELD_TYPE.eq(type_) | GROUP_TYPE.eq(type_) | INT_TYPES.contains(type_), - format!("{FIELD_TYPE}, {GROUP_TYPE}, {}", types_to_string(&INT_TYPES),), - type_, - span, - ) + pub(crate) fn assert_int_type(&self, type_: &Type, span: Span) { + if !matches!(type_, Type::Err | Type::Integer(_)) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "an integer", span)); + } } - /// Emits an error to the handler if the given type is not a field, group, or signed integer. - pub(crate) fn assert_field_group_signed_int_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| FIELD_TYPE.eq(type_) | GROUP_TYPE.eq(type_) | SIGNED_INT_TYPES.contains(type_), - format!("{FIELD_TYPE}, {GROUP_TYPE}, {}", types_to_string(&SIGNED_INT_TYPES),), + pub(crate) fn assert_unsigned_type(&self, type_: &Type, span: Span) { + if !matches!( type_, - span, - ) + Type::Err + | Type::Integer(IntegerType::U8) + | Type::Integer(IntegerType::U16) + | Type::Integer(IntegerType::U32) + | Type::Integer(IntegerType::U64) + | Type::Integer(IntegerType::U128) + ) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "an unsigned integer", span)); + } } - /// Emits an error to the handler if the given type is not a field, scalar, or integer. - pub(crate) fn assert_field_scalar_int_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| FIELD_TYPE.eq(type_) | SCALAR_TYPE.eq(type_) | INT_TYPES.contains(type_), - format!("{FIELD_TYPE}, {SCALAR_TYPE}, {}", types_to_string(&INT_TYPES),), + pub(crate) fn assert_bool_int_type(&self, type_: &Type, span: Span) { + if !matches!( type_, - span, - ) + Type::Err + | Type::Boolean + | Type::Integer(IntegerType::U8) + | Type::Integer(IntegerType::U16) + | Type::Integer(IntegerType::U32) + | Type::Integer(IntegerType::U64) + | Type::Integer(IntegerType::U128) + | Type::Integer(IntegerType::I8) + | Type::Integer(IntegerType::I16) + | Type::Integer(IntegerType::I32) + | Type::Integer(IntegerType::I64) + | Type::Integer(IntegerType::I128) + ) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "a bool or integer", span)); + } } - /// Emits an error to the handler if the given type is not a field, group, scalar, integer, or boolean. - pub(crate) fn assert_field_group_scalar_int_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| { - FIELD_TYPE.eq(type_) | GROUP_TYPE.eq(type_) | SCALAR_TYPE.eq(type_) | INT_TYPES.contains(type_) - }, - format!("{}, {}, {}, {}", FIELD_TYPE, GROUP_TYPE, SCALAR_TYPE, types_to_string(&INT_TYPES),), + pub(crate) fn assert_field_int_type(&self, type_: &Type, span: Span) { + if !matches!( type_, - span, - ) + Type::Err + | Type::Field + | Type::Integer(IntegerType::U8) + | Type::Integer(IntegerType::U16) + | Type::Integer(IntegerType::U32) + | Type::Integer(IntegerType::U64) + | Type::Integer(IntegerType::U128) + | Type::Integer(IntegerType::I8) + | Type::Integer(IntegerType::I16) + | Type::Integer(IntegerType::I32) + | Type::Integer(IntegerType::I64) + | Type::Integer(IntegerType::I128) + ) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "a field or integer", span)); + } } - /// Emits an error to the handler if the given type is not a field, group, scalar, integer, boolean, or address. - pub(crate) fn assert_castable_type(&self, type_: &Option, span: Span) { - self.check_type( - |type_: &Type| { - FIELD_TYPE.eq(type_) - | GROUP_TYPE.eq(type_) - | SCALAR_TYPE.eq(type_) - | INT_TYPES.contains(type_) - | BOOLEAN_TYPE.eq(type_) - | ADDRESS_TYPE.eq(type_) - }, - format!( - "{}, {}, {}, {}, {}, {}", - FIELD_TYPE, - GROUP_TYPE, - SCALAR_TYPE, - types_to_string(&INT_TYPES), - BOOLEAN_TYPE, - ADDRESS_TYPE - ), - type_, - span, - ) + pub(crate) fn assert_field_group_int_type(&self, type_: &Type, span: Span) { + if !matches!(type_, Type::Err | Type::Field | Type::Group | Type::Integer(_)) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "a field, group, or integer", span)); + } } /// Type checks the inputs to an associated constant and returns the expected output type. @@ -388,9 +250,9 @@ impl<'a, N: Network> TypeChecker<'a, N> { pub(crate) fn check_core_function_call( &mut self, core_function: CoreFunction, - arguments: &[(Option, Span)], + arguments: &[(Type, Span)], function_span: Span, - ) -> Option { + ) -> Type { // Check that the number of arguments is correct. if arguments.len() != core_function.num_args() { self.emit_err(TypeCheckerError::incorrect_num_args_to_call( @@ -398,61 +260,60 @@ impl<'a, N: Network> TypeChecker<'a, N> { arguments.len(), function_span, )); - return None; + return Type::Err; } - // Helper to check that the type of argument is not a mapping, tuple, err, or unit type. - let check_not_mapping_tuple_err_unit = |type_: &Option, span: &Span| { - self.check_type( - |type_: &Type| !matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Err | Type::Unit), - "address, bool, field, group, struct, integer, scalar, struct".to_string(), - type_, - *span, - ); + let assert_not_mapping_tuple_unit = |type_: &Type, span: Span| { + if matches!(type_, Type::Mapping(_) | Type::Tuple(_) | Type::Unit) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "anything but a mapping, tuple, or unit", span)); + } }; - // Helper to check that the type of the argument is a valid input to a Pedersen hash/commit with 64-bit inputs. - // The console types in snarkVM have some overhead in their bitwise representation. Consequently, Pedersen64 cannot accept a u64. - let check_pedersen_64_bit_input = |type_: &Option, span: &Span| { - self.check_type( - |type_: &Type| { - !matches!( - type_, - Type::Integer(IntegerType::U64) - | Type::Integer(IntegerType::I64) - | Type::Integer(IntegerType::U128) - | Type::Integer(IntegerType::I128) - | Type::Mapping(_) - | Type::Tuple(_) - | Type::Err - | Type::Unit - ) - }, - "address, bool, field, group, struct, integer, scalar, struct".to_string(), + // Make sure the input is no bigger than 64 bits. + // Due to overhead in the bitwise representations of types in SnarkVM, 64 bit integers + // input more than 64 bits to a hash function. + let assert_pedersen_64_bit_input = |type_: &Type, span: Span| { + if !matches!( type_, - *span, - ); + Type::Integer(IntegerType::U8) + | Type::Integer(IntegerType::U16) + | Type::Integer(IntegerType::U32) + | Type::Integer(IntegerType::I8) + | Type::Integer(IntegerType::I16) + | Type::Integer(IntegerType::I32) + | Type::Boolean + | Type::Err + ) { + self.emit_err(TypeCheckerError::type_should_be2( + type_, + "an integer of less than 64 bits or a bool", + span, + )); + } }; - // Helper to check that the type of the argument is a valid input to a Pedersen hash/commit with 128-bit inputs. - // The console types in snarkVM have some overhead in their bitwise representation. Consequently, Pedersen128 cannot accept a u128. - let check_pedersen_128_bit_input = |type_: &Option, span: &Span| { - self.check_type( - |type_: &Type| { - !matches!( - type_, - Type::Integer(IntegerType::U128) - | Type::Integer(IntegerType::I128) - | Type::Mapping(_) - | Type::Tuple(_) - | Type::Err - | Type::Unit - ) - }, - "address, bool, field, group, struct, integer, scalar, struct".to_string(), + // Make sure the input is no bigger than 128 bits. + let assert_pedersen_128_bit_input = |type_: &Type, span: Span| { + // This is presumably a little more conservative than necessary. + if !matches!( type_, - *span, - ); + Type::Integer(IntegerType::U8) + | Type::Integer(IntegerType::U16) + | Type::Integer(IntegerType::U32) + | Type::Integer(IntegerType::U64) + | Type::Integer(IntegerType::I8) + | Type::Integer(IntegerType::I16) + | Type::Integer(IntegerType::I32) + | Type::Integer(IntegerType::I64) + | Type::Boolean + | Type::Err + ) { + self.emit_err(TypeCheckerError::type_should_be2( + type_, + "an integer of less than 128 bits or a bool", + span, + )); + } }; // Check that the arguments are of the correct type. @@ -461,31 +322,25 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::BHP512CommitToAddress | CoreFunction::BHP768CommitToAddress | CoreFunction::BHP1024CommitToAddress => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - Some(Type::Address) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Address } CoreFunction::BHP256CommitToField | CoreFunction::BHP512CommitToField | CoreFunction::BHP768CommitToField | CoreFunction::BHP1024CommitToField => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - Some(Type::Field) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Field } CoreFunction::BHP256CommitToGroup | CoreFunction::BHP512CommitToGroup | CoreFunction::BHP768CommitToGroup | CoreFunction::BHP1024CommitToGroup => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - Some(Type::Group) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Group } CoreFunction::BHP256HashToAddress | CoreFunction::BHP512HashToAddress @@ -500,9 +355,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToAddress | CoreFunction::SHA3_384HashToAddress | CoreFunction::SHA3_512HashToAddress => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Address) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Address } CoreFunction::BHP256HashToField | CoreFunction::BHP512HashToField @@ -517,9 +371,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToField | CoreFunction::SHA3_384HashToField | CoreFunction::SHA3_512HashToField => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Field) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Field } CoreFunction::BHP256HashToGroup | CoreFunction::BHP512HashToGroup @@ -534,9 +387,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToGroup | CoreFunction::SHA3_384HashToGroup | CoreFunction::SHA3_512HashToGroup => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Group) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Group } CoreFunction::BHP256HashToI8 | CoreFunction::BHP512HashToI8 @@ -551,9 +403,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToI8 | CoreFunction::SHA3_384HashToI8 | CoreFunction::SHA3_512HashToI8 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I8)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I8) } CoreFunction::BHP256HashToI16 | CoreFunction::BHP512HashToI16 @@ -568,9 +419,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToI16 | CoreFunction::SHA3_384HashToI16 | CoreFunction::SHA3_512HashToI16 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I16)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I16) } CoreFunction::BHP256HashToI32 | CoreFunction::BHP512HashToI32 @@ -585,9 +435,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToI32 | CoreFunction::SHA3_384HashToI32 | CoreFunction::SHA3_512HashToI32 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I32)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I32) } CoreFunction::BHP256HashToI64 | CoreFunction::BHP512HashToI64 @@ -602,9 +451,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToI64 | CoreFunction::SHA3_384HashToI64 | CoreFunction::SHA3_512HashToI64 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I64)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I64) } CoreFunction::BHP256HashToI128 | CoreFunction::BHP512HashToI128 @@ -619,9 +467,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToI128 | CoreFunction::SHA3_384HashToI128 | CoreFunction::SHA3_512HashToI128 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I128)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I128) } CoreFunction::BHP256HashToU8 | CoreFunction::BHP512HashToU8 @@ -636,9 +483,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToU8 | CoreFunction::SHA3_384HashToU8 | CoreFunction::SHA3_512HashToU8 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U8)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U8) } CoreFunction::BHP256HashToU16 | CoreFunction::BHP512HashToU16 @@ -653,9 +499,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToU16 | CoreFunction::SHA3_384HashToU16 | CoreFunction::SHA3_512HashToU16 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U16)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U16) } CoreFunction::BHP256HashToU32 | CoreFunction::BHP512HashToU32 @@ -670,9 +515,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToU32 | CoreFunction::SHA3_384HashToU32 | CoreFunction::SHA3_512HashToU32 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U32)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U32) } CoreFunction::BHP256HashToU64 | CoreFunction::BHP512HashToU64 @@ -687,9 +531,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToU64 | CoreFunction::SHA3_384HashToU64 | CoreFunction::SHA3_512HashToU64 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U64)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U64) } CoreFunction::BHP256HashToU128 | CoreFunction::BHP512HashToU128 @@ -704,9 +547,8 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToU128 | CoreFunction::SHA3_384HashToU128 | CoreFunction::SHA3_512HashToU128 => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U128)) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U128) } CoreFunction::BHP256HashToScalar | CoreFunction::BHP512HashToScalar @@ -721,327 +563,281 @@ impl<'a, N: Network> TypeChecker<'a, N> { | CoreFunction::SHA3_256HashToScalar | CoreFunction::SHA3_384HashToScalar | CoreFunction::SHA3_512HashToScalar => { - // Check that the first argument is not a mapping, tuple, err, or unit type. - check_not_mapping_tuple_err_unit(&arguments[0].0, &arguments[0].1); - Some(Type::Scalar) + assert_not_mapping_tuple_unit(&arguments[0].0, arguments[0].1); + Type::Scalar } CoreFunction::Pedersen64CommitToAddress => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - - Some(Type::Address) + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Address } CoreFunction::Pedersen64CommitToField => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - - Some(Type::Field) + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Field } CoreFunction::Pedersen64CommitToGroup => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - - Some(Type::Group) + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Group } CoreFunction::Pedersen64HashToAddress => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Address) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Address } CoreFunction::Pedersen64HashToField => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Field) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Field } CoreFunction::Pedersen64HashToGroup => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Group) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Group } CoreFunction::Pedersen64HashToI8 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I8)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I8) } CoreFunction::Pedersen64HashToI16 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I16)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I16) } CoreFunction::Pedersen64HashToI32 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I32)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I32) } CoreFunction::Pedersen64HashToI64 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I64)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I64) } CoreFunction::Pedersen64HashToI128 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I128)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I128) } CoreFunction::Pedersen64HashToU8 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U8)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U8) } CoreFunction::Pedersen64HashToU16 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U16)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U16) } CoreFunction::Pedersen64HashToU32 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U32)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U32) } CoreFunction::Pedersen64HashToU64 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U64)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U64) } CoreFunction::Pedersen64HashToU128 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U128)) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U128) } CoreFunction::Pedersen64HashToScalar => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 32 bits. - check_pedersen_64_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Scalar) + assert_pedersen_64_bit_input(&arguments[0].0, arguments[0].1); + Type::Scalar } CoreFunction::Pedersen128CommitToAddress => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - - Some(Type::Address) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Address } CoreFunction::Pedersen128CommitToField => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - - Some(Type::Field) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Field } CoreFunction::Pedersen128CommitToGroup => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - // Check that the second argument is a scalar. - self.assert_scalar_type(&arguments[1].0, arguments[1].1); - - Some(Type::Group) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + self.assert_type(&arguments[1].0, &Type::Scalar, arguments[1].1); + Type::Group } CoreFunction::Pedersen128HashToAddress => { // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Address) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Address } CoreFunction::Pedersen128HashToField => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Field) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Field } CoreFunction::Pedersen128HashToGroup => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Group) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Group } CoreFunction::Pedersen128HashToI8 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I8)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I8) } CoreFunction::Pedersen128HashToI16 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I16)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I16) } CoreFunction::Pedersen128HashToI32 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I32)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I32) } CoreFunction::Pedersen128HashToI64 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I64)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I64) } CoreFunction::Pedersen128HashToI128 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::I128)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::I128) } CoreFunction::Pedersen128HashToU8 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U8)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U8) } CoreFunction::Pedersen128HashToU16 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U16)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U16) } CoreFunction::Pedersen128HashToU32 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U32)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U32) } CoreFunction::Pedersen128HashToU64 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U64)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U64) } CoreFunction::Pedersen128HashToU128 => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Integer(IntegerType::U128)) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Integer(IntegerType::U128) } CoreFunction::Pedersen128HashToScalar => { - // Check that the first argument is not a mapping, tuple, err, unit type, or integer over 64 bits. - check_pedersen_128_bit_input(&arguments[0].0, &arguments[0].1); - Some(Type::Scalar) + assert_pedersen_128_bit_input(&arguments[0].0, arguments[0].1); + Type::Scalar } CoreFunction::MappingGet => { // Check that the operation is invoked in a `finalize` block. self.check_access_allowed("Mapping::get", true, function_span); // Check that the first argument is a mapping. - if let Some(mapping_type) = self.assert_mapping_type(&arguments[0].0, arguments[0].1) { - // Check that the second argument matches the key type of the mapping. - self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); - // Return the value type of the mapping. - Some(*mapping_type.value) - } else { - None - } + self.assert_mapping_type(&arguments[0].0, arguments[0].1); + let Type::Mapping(mapping_type) = &arguments[0].0 else { + // We will have already handled the error in the assertion. + return Type::Err; + }; + + self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); + + mapping_type.value.deref().clone() } CoreFunction::MappingGetOrUse => { // Check that the operation is invoked in a `finalize` block. self.check_access_allowed("Mapping::get_or", true, function_span); // Check that the first argument is a mapping. - if let Some(mapping_type) = self.assert_mapping_type(&arguments[0].0, arguments[0].1) { - // Check that the second argument matches the key type of the mapping. - self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); - // Check that the third argument matches the value type of the mapping. - self.assert_type(&arguments[2].0, &mapping_type.value, arguments[2].1); - // Return the value type of the mapping. - Some(*mapping_type.value) - } else { - None - } + self.assert_mapping_type(&arguments[0].0, arguments[0].1); + + let Type::Mapping(mapping_type) = &arguments[0].0 else { + // We will have already handled the error in the assertion. + return Type::Err; + }; + + // Check that the second argument matches the key type of the mapping. + self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); + // Check that the third argument matches the value type of the mapping. + self.assert_type(&arguments[2].0, &mapping_type.value, arguments[2].1); + + mapping_type.value.deref().clone() } CoreFunction::MappingSet => { // Check that the operation is invoked in a `finalize` block. self.check_access_allowed("Mapping::set", true, function_span); // Check that the first argument is a mapping. - if let Some(mapping_type) = self.assert_mapping_type(&arguments[0].0, arguments[0].1) { - // Cannot modify external mappings. - if mapping_type.program != self.scope_state.program_name.unwrap() { - self.handler.emit_err(TypeCheckerError::cannot_modify_external_mapping("set", function_span)); - } - // Check that the second argument matches the key type of the mapping. - self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); - // Check that the third argument matches the value type of the mapping. - self.assert_type(&arguments[2].0, &mapping_type.value, arguments[2].1); - // Return the mapping type. - Some(Type::Unit) - } else { - None - } + self.assert_mapping_type(&arguments[0].0, arguments[0].1); + + let Type::Mapping(mapping_type) = &arguments[0].0 else { + // We will have already handled the error in the assertion. + return Type::Err; + }; + + // Check that the second argument matches the key type of the mapping. + self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); + // Check that the third argument matches the value type of the mapping. + self.assert_type(&arguments[2].0, &mapping_type.value, arguments[2].1); + + Type::Unit } CoreFunction::MappingRemove => { // Check that the operation is invoked in a `finalize` block. self.check_access_allowed("Mapping::remove", true, function_span); // Check that the first argument is a mapping. - if let Some(mapping_type) = self.assert_mapping_type(&arguments[0].0, arguments[0].1) { - // Cannot modify external mappings. - if mapping_type.program != self.scope_state.program_name.unwrap() { - self.handler - .emit_err(TypeCheckerError::cannot_modify_external_mapping("remove", function_span)); - } - // Check that the second argument matches the key type of the mapping. - self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); - // Return nothing. - Some(Type::Unit) - } else { - None + self.assert_mapping_type(&arguments[0].0, arguments[0].1); + + let Type::Mapping(mapping_type) = &arguments[0].0 else { + // We will have already handled the error in the assertion. + return Type::Err; + }; + + // Cannot modify external mappings. + if mapping_type.program != self.scope_state.program_name.unwrap() { + self.handler.emit_err(TypeCheckerError::cannot_modify_external_mapping("remove", function_span)); } + + // Check that the second argument matches the key type of the mapping. + self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); + + Type::Unit } CoreFunction::MappingContains => { // Check that the operation is invoked in a `finalize` block. self.check_access_allowed("Mapping::contains", true, function_span); // Check that the first argument is a mapping. - if let Some(mapping_type) = self.assert_mapping_type(&arguments[0].0, arguments[0].1) { - // Check that the second argument matches the key type of the mapping. - self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); - // Return a boolean. - Some(Type::Boolean) - } else { - None - } + self.assert_mapping_type(&arguments[0].0, arguments[0].1); + + let Type::Mapping(mapping_type) = &arguments[0].0 else { + // We will have already handled the error in the assertion. + return Type::Err; + }; + + // Check that the second argument matches the key type of the mapping. + self.assert_type(&arguments[1].0, &mapping_type.key, arguments[1].1); + + Type::Boolean } CoreFunction::GroupToXCoordinate | CoreFunction::GroupToYCoordinate => { // Check that the first argument is a group. - self.assert_group_type(&arguments[0].0, arguments[0].1); - Some(Type::Field) - } - CoreFunction::ChaChaRandAddress => Some(Type::Address), - CoreFunction::ChaChaRandBool => Some(Type::Boolean), - CoreFunction::ChaChaRandField => Some(Type::Field), - CoreFunction::ChaChaRandGroup => Some(Type::Group), - CoreFunction::ChaChaRandI8 => Some(Type::Integer(IntegerType::I8)), - CoreFunction::ChaChaRandI16 => Some(Type::Integer(IntegerType::I16)), - CoreFunction::ChaChaRandI32 => Some(Type::Integer(IntegerType::I32)), - CoreFunction::ChaChaRandI64 => Some(Type::Integer(IntegerType::I64)), - CoreFunction::ChaChaRandI128 => Some(Type::Integer(IntegerType::I128)), - CoreFunction::ChaChaRandScalar => Some(Type::Scalar), - CoreFunction::ChaChaRandU8 => Some(Type::Integer(IntegerType::U8)), - CoreFunction::ChaChaRandU16 => Some(Type::Integer(IntegerType::U16)), - CoreFunction::ChaChaRandU32 => Some(Type::Integer(IntegerType::U32)), - CoreFunction::ChaChaRandU64 => Some(Type::Integer(IntegerType::U64)), - CoreFunction::ChaChaRandU128 => Some(Type::Integer(IntegerType::U128)), + self.assert_type(&arguments[0].0, &Type::Group, arguments[0].1); + Type::Field + } + CoreFunction::ChaChaRandAddress => Type::Address, + CoreFunction::ChaChaRandBool => Type::Boolean, + CoreFunction::ChaChaRandField => Type::Field, + CoreFunction::ChaChaRandGroup => Type::Group, + CoreFunction::ChaChaRandI8 => Type::Integer(IntegerType::I8), + CoreFunction::ChaChaRandI16 => Type::Integer(IntegerType::I16), + CoreFunction::ChaChaRandI32 => Type::Integer(IntegerType::I32), + CoreFunction::ChaChaRandI64 => Type::Integer(IntegerType::I64), + CoreFunction::ChaChaRandI128 => Type::Integer(IntegerType::I128), + CoreFunction::ChaChaRandScalar => Type::Scalar, + CoreFunction::ChaChaRandU8 => Type::Integer(IntegerType::U8), + CoreFunction::ChaChaRandU16 => Type::Integer(IntegerType::U16), + CoreFunction::ChaChaRandU32 => Type::Integer(IntegerType::U32), + CoreFunction::ChaChaRandU64 => Type::Integer(IntegerType::U64), + CoreFunction::ChaChaRandU128 => Type::Integer(IntegerType::U128), CoreFunction::SignatureVerify => { // Check that the first argument is a signature. - self.assert_signature_type(&arguments[0].0, arguments[0].1); + self.assert_type(&arguments[0].0, &Type::Signature, arguments[0].1); // Check that the second argument is an address. - self.assert_address_type(&arguments[1].0, arguments[1].1); - // Return a boolean. - Some(Type::Boolean) + self.assert_type(&arguments[1].0, &Type::Address, arguments[1].1); + Type::Boolean } - CoreFunction::FutureAwait => Some(Type::Unit), + CoreFunction::FutureAwait => Type::Unit, CoreFunction::CheatCodePrintMapping => { - // Check that the argument is a mapping. - let _ = self.assert_mapping_type(&arguments[0].0, arguments[0].1); - Some(Type::Unit) + self.assert_mapping_type(&arguments[0].0, arguments[0].1); + Type::Unit } CoreFunction::CheatCodeSetBlockHeight => { - // Assert that the argument is a u32. self.assert_type(&arguments[0].0, &Type::Integer(IntegerType::U32), arguments[0].1); - Some(Type::Unit) + Type::Unit } } } - /// Returns the `struct` type and emits an error if the `expected` type does not match. - pub(crate) fn check_expected_struct(&mut self, struct_: &Composite, expected: &Option, span: Span) -> Type { - let current_struct = CompositeType { id: struct_.identifier, program: struct_.external }; - if expected.is_some() { - self.check_eq_types(&Some(Type::Composite(current_struct)), expected, span); - } - Type::Composite(current_struct) - } - /// Emits an error if the struct member is a record type. pub(crate) fn assert_member_is_not_record(&mut self, span: Span, parent: Symbol, type_: &Type) { match type_ { @@ -1121,17 +917,16 @@ impl<'a, N: Network> TypeChecker<'a, N> { } /// Emits an error if the type is not a mapping. - pub(crate) fn assert_mapping_type(&self, type_: &Option, span: Span) -> Option { - self.check_type(|type_| matches!(type_, Type::Mapping(_)), "mapping".to_string(), type_, span); - match type_ { - Some(Type::Mapping(mapping_type)) => Some(mapping_type.clone()), - _ => None, + pub(crate) fn assert_mapping_type(&self, type_: &Type, span: Span) { + if type_ != &Type::Err && !matches!(type_, Type::Mapping(_)) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "a mapping", span)); } } - /// Emits an error if the type is not an array. - pub(crate) fn assert_array_type(&self, type_: &Option, span: Span) { - self.check_type(|type_| matches!(type_, Type::Array(_)), "array".to_string(), type_, span); + pub(crate) fn assert_array_type(&self, type_: &Type, span: Span) { + if type_ != &Type::Err && !matches!(type_, Type::Array(_)) { + self.emit_err(TypeCheckerError::type_should_be2(type_, "an array", span)); + } } /// Helper function to check that the input and output of function are valid @@ -1308,6 +1103,52 @@ impl<'a, N: Network> TypeChecker<'a, N> { }); } + /// Are the types considered equal as far as the Leo user is concerned? + /// + /// In particular, any comparison involving an `Err` is `true`, + /// composite types are resolved to the current program if not specified, + /// and Futures which aren't explicit compare equal to other Futures. + pub(crate) fn eq_user(&self, t1: &Type, t2: &Type) -> bool { + match (t1, t2) { + (Type::Err, _) + | (_, Type::Err) + | (Type::Address, Type::Address) + | (Type::Boolean, Type::Boolean) + | (Type::Field, Type::Field) + | (Type::Group, Type::Group) + | (Type::Scalar, Type::Scalar) + | (Type::Signature, Type::Signature) + | (Type::String, Type::String) + | (Type::Unit, Type::Unit) => true, + (Type::Array(left), Type::Array(right)) => { + left.length() == right.length() && self.eq_user(left.element_type(), right.element_type()) + } + (Type::Identifier(left), Type::Identifier(right)) => left.name == right.name, + (Type::Integer(left), Type::Integer(right)) => left == right, + (Type::Mapping(left), Type::Mapping(right)) => { + self.eq_user(&left.key, &right.key) && self.eq_user(&left.value, &right.value) + } + (Type::Tuple(left), Type::Tuple(right)) if left.length() == right.length() => left + .elements() + .iter() + .zip_eq(right.elements().iter()) + .all(|(left_type, right_type)| self.eq_user(left_type, right_type)), + (Type::Composite(left), Type::Composite(right)) => { + let left_program = left.program.or(self.scope_state.program_name); + let right_program = right.program.or(self.scope_state.program_name); + + left.id.name == right.id.name && left_program == right_program + } + (Type::Future(left), Type::Future(right)) if !left.is_explicit || !right.is_explicit => true, + (Type::Future(left), Type::Future(right)) if left.inputs.len() == right.inputs.len() => left + .inputs() + .iter() + .zip_eq(right.inputs().iter()) + .all(|(left_type, right_type)| self.eq_user(left_type, right_type)), + _ => false, + } + } + /// Wrapper around lookup_struct that additionally records all structs that are used in the program. pub(crate) fn lookup_struct(&mut self, program: Option, name: Symbol) -> Option { let struct_ = self @@ -1360,7 +1201,3 @@ impl<'a, N: Network> TypeChecker<'a, N> { } } } - -fn types_to_string(types: &[Type]) -> String { - types.iter().map(|type_| type_.to_string()).join(", ") -} diff --git a/errors/src/errors/type_checker/type_checker_error.rs b/errors/src/errors/type_checker/type_checker_error.rs index 1ec82fc902..3a44cd2d22 100644 --- a/errors/src/errors/type_checker/type_checker_error.rs +++ b/errors/src/errors/type_checker/type_checker_error.rs @@ -819,8 +819,8 @@ create_messages!( @formatted external_transition_call_must_be_before_finalize { args: (), - msg: "External async transition calls cannot be made after local async function call".to_string(), - help: Some("Move the async call before the function call.".to_string()), + msg: "External transition calls cannot be made after local async function call".to_string(), + help: Some("Move the async function call before the transition call.".to_string()), } @formatted @@ -919,4 +919,61 @@ create_messages!( msg: format!("Futures may only appear as parameters to async functions."), help: None, } + + /// For when the user tries to assign to a const input. + /// + /// This is a replacement for `type_should_be` with a slightly better message. + @formatted + type_should_be2 { + args: (type_: impl Display, expected: impl Display), + msg: format!( + "Expected {expected} but type `{type_}` was found.", + ), + help: None, + } + + @formatted + ternary_branch_mismatch { + args: (type1: impl Display, type2: impl Display), + msg: format!( + "Received different types `{type1}` and `{type2}` for the arms of a ternary conditional." + ), + help: Some("Make both branches the same type.".into()), + } + + @formatted + operation_types_mismatch { + args: (operation: impl Display, type1: impl Display, type2: impl Display), + msg: format!( + "Received different types `{type1}` and `{type2}` for the operation `{operation}`." + ), + help: Some("Make both operands the same type.".into()), + } + + @formatted + mul_types_mismatch { + args: (type1: impl Display, type2: impl Display), + msg: format!( + "Received types `{type1}` and `{type2}` for the operation `*`." + ), + help: Some("Valid operands are two integers of the same type, two fields, or a scalar and a group.".into()), + } + + @formatted + pow_types_mismatch { + args: (type1: impl Display, type2: impl Display), + msg: format!( + "Received types `{type1}` and `{type2}` for the operation `pow`." + ), + help: Some("Valid operands are two fields, or an integer base and a `u8`, `u16`, or `u32` exponent.".into()), + } + + @formatted + shift_type_magnitude { + args: (operation: impl Display, rhs_type: impl Display), + msg: format!( + "Received type `{rhs_type}` for the second operand of the operation `{operation}`." + ), + help: Some("Valid second operands are `u8`, `u16`, or `u32`".into()), + } ); diff --git a/tests/expectations/compiler/address/gt_fail.out b/tests/expectations/compiler/address/gt_fail.out index ddcedee123..e80958e725 100644 --- a/tests/expectations/compiler/address/gt_fail.out +++ b/tests/expectations/compiler/address/gt_fail.out @@ -1,11 +1,16 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372021]: Comparison `>` is not supported for the address type. +Error [ETYC0372117]: Expected a field, scalar, or integer but type `address` was found. --> compiler-test:7:16 | 7 | return x > sender; - | ^^^^^^^^^^ + | ^ +Error [ETYC0372117]: Expected a field, scalar, or integer but type `address` was found. + --> compiler-test:7:20 + | + 7 | return x > sender; + | ^^^^^^ Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/address/gte_fail.out b/tests/expectations/compiler/address/gte_fail.out index a1091337ef..a7c03690b9 100644 --- a/tests/expectations/compiler/address/gte_fail.out +++ b/tests/expectations/compiler/address/gte_fail.out @@ -1,11 +1,16 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372021]: Comparison `>=` is not supported for the address type. +Error [ETYC0372117]: Expected a field, scalar, or integer but type `address` was found. --> compiler-test:7:16 | 7 | return x >= sender; - | ^^^^^^^^^^^ + | ^ +Error [ETYC0372117]: Expected a field, scalar, or integer but type `address` was found. + --> compiler-test:7:21 + | + 7 | return x >= sender; + | ^^^^^^ Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/address/lt_fail.out b/tests/expectations/compiler/address/lt_fail.out index 401cadb145..b7e0fd415b 100644 --- a/tests/expectations/compiler/address/lt_fail.out +++ b/tests/expectations/compiler/address/lt_fail.out @@ -1,11 +1,16 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372021]: Comparison `<` is not supported for the address type. +Error [ETYC0372117]: Expected a field, scalar, or integer but type `address` was found. --> compiler-test:7:16 | 7 | return x < sender; - | ^^^^^^^^^^ + | ^ +Error [ETYC0372117]: Expected a field, scalar, or integer but type `address` was found. + --> compiler-test:7:20 + | + 7 | return x < sender; + | ^^^^^^ Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/address/lte_fail.out b/tests/expectations/compiler/address/lte_fail.out index 14995496f0..6d9f8f8379 100644 --- a/tests/expectations/compiler/address/lte_fail.out +++ b/tests/expectations/compiler/address/lte_fail.out @@ -1,11 +1,16 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372021]: Comparison `<=` is not supported for the address type. +Error [ETYC0372117]: Expected a field, scalar, or integer but type `address` was found. --> compiler-test:7:16 | 7 | return x <= sender; - | ^^^^^^^^^^^ + | ^ +Error [ETYC0372117]: Expected a field, scalar, or integer but type `address` was found. + --> compiler-test:7:21 + | + 7 | return x <= sender; + | ^^^^^^ Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/array/array_in_composite_data_types.out b/tests/expectations/compiler/array/array_in_composite_data_types.out index 20dd329cec..42793a0080 100644 --- a/tests/expectations/compiler/array/array_in_composite_data_types.out +++ b/tests/expectations/compiler/array/array_in_composite_data_types.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "4f8ab92e1b0589f9f72c264bded41a74ab81a95c0863bbb2128c2e455f8940ce", type_checked_symbol_table = "80855e8466f2d8c141ade84f032cd8e08d31253bd9ed6d5961e22ed21fa60758", unrolled_symbol_table = "80855e8466f2d8c141ade84f032cd8e08d31253bd9ed6d5961e22ed21fa60758", initial_ast = "85c3840f1f944a2935fb3c72572498e35718479567668c2021b58c351770e687", unrolled_ast = "85c3840f1f944a2935fb3c72572498e35718479567668c2021b58c351770e687", ssa_ast = "d0361696dcc37db64ddb4dd16c46da32544b40473ab527a7ead74006e606aa27", flattened_ast = "62ed1887b901a2595b4a0501739273c9a1be99f7087d69dc0c3ea3e3ad7608a3", destructured_ast = "1269eb8715c7b65336f707b4a034353214600e240b5771bc1c7ce20630cd8b08", inlined_ast = "1269eb8715c7b65336f707b4a034353214600e240b5771bc1c7ce20630cd8b08", dce_ast = "1269eb8715c7b65336f707b4a034353214600e240b5771bc1c7ce20630cd8b08", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "25dab89309e5e0c7c8b71b31f2a36741154e2e57cc3fed67f885cb8658efe092", type_checked_symbol_table = "b5ff59ba45bfb803d4b6f49cae6a0a615b4672f662b4a432919a4db1cc21ce54", unrolled_symbol_table = "b5ff59ba45bfb803d4b6f49cae6a0a615b4672f662b4a432919a4db1cc21ce54", initial_ast = "df75ddc12225ac6a386c0c3eef00e66e0944691fc384b27096c5daf0a103e0ce", unrolled_ast = "df75ddc12225ac6a386c0c3eef00e66e0944691fc384b27096c5daf0a103e0ce", ssa_ast = "ed2178a2a85bdf8b1775fafe950fc81d25e6b144a51e30faa7370adda15f4151", flattened_ast = "77faef8d0b740f66a77d17a9a194a2c34fecd583862077d7c9f04da952f00e7f", destructured_ast = "94bd5ab71dfad6a18a92fd4ea2bbf7fb8f45f39572554b14df25228f29e6ae75", inlined_ast = "94bd5ab71dfad6a18a92fd4ea2bbf7fb8f45f39572554b14df25228f29e6ae75", dce_ast = "94bd5ab71dfad6a18a92fd4ea2bbf7fb8f45f39572554b14df25228f29e6ae75", bytecode = """ program test.aleo; struct bar: diff --git a/tests/expectations/compiler/array/array_initialization_fail.out b/tests/expectations/compiler/array/array_initialization_fail.out index 4b64140084..831805c8ac 100644 --- a/tests/expectations/compiler/array/array_initialization_fail.out +++ b/tests/expectations/compiler/array/array_initialization_fail.out @@ -1,12 +1,12 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `[bool; 8]` but type `[bool; 7]` was found +Error [ETYC0372117]: Expected type `[bool; 8]` but type `[bool; 7]` was found. --> compiler-test:5:16 | 5 | return [a, a, a, a, a, a, a]; | ^^^^^^^^^^^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `u8` but type `u32` was found +Error [ETYC0372117]: Expected type `u8` but type `u32` was found. --> compiler-test:9:52 | 9 | return [1u8, 2u8, 3u8, 4u8, 5u8, 6u8, 7u8, 8u32]; diff --git a/tests/expectations/compiler/array/array_of_structs.out b/tests/expectations/compiler/array/array_of_structs.out index 55484f5f8d..82c3964726 100644 --- a/tests/expectations/compiler/array/array_of_structs.out +++ b/tests/expectations/compiler/array/array_of_structs.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "2810f9059b0a96a9416ee2a7212debabcb4bc6802095bdff039065d3fda7f3c7", type_checked_symbol_table = "b6307badfe522266447d5503e92045f5935d26a0c13cbcc7d78f0da6b6128a0b", unrolled_symbol_table = "b6307badfe522266447d5503e92045f5935d26a0c13cbcc7d78f0da6b6128a0b", initial_ast = "c5174335068d386bf09f1613ddc2765ab788afbce0a83dc94c8197d792570324", unrolled_ast = "c5174335068d386bf09f1613ddc2765ab788afbce0a83dc94c8197d792570324", ssa_ast = "ec179cc367b277c201b59fc08a6063297f826e09867caf663f30629a0d6bc8e4", flattened_ast = "cdd4b046fda370d0630b92e41a7544214dd31b5b58c830f40ac93c5b4e33e542", destructured_ast = "19737108a3b3f9a45517e31a0d273c74ae5cda9c8bc86480c96317e6cd33d478", inlined_ast = "19737108a3b3f9a45517e31a0d273c74ae5cda9c8bc86480c96317e6cd33d478", dce_ast = "19737108a3b3f9a45517e31a0d273c74ae5cda9c8bc86480c96317e6cd33d478", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "a619a11441157fb2839072b92e550161cd828647d9b105708e0fc09cda8948c9", type_checked_symbol_table = "02b483cf4c923a200655561856b49080ca10f1054012b9f9b2aa8e4316d01dee", unrolled_symbol_table = "02b483cf4c923a200655561856b49080ca10f1054012b9f9b2aa8e4316d01dee", initial_ast = "d10f263df43d11f80f4680fa77584cbc84821340f3d4988a71123a23d91c6568", unrolled_ast = "d10f263df43d11f80f4680fa77584cbc84821340f3d4988a71123a23d91c6568", ssa_ast = "34e840d725a0480f04bf8ce09126011132cd3e0e0385a91222380ac11096e1c1", flattened_ast = "1b310e6f2ac91a36840b8d5e77ddcaa32c1cb2b78cea171c694ca9aaa11a4265", destructured_ast = "d0248ad1b4f8df9edea988d5576c4cc29cfb991d63a1e4f77dd473137bc044a0", inlined_ast = "d0248ad1b4f8df9edea988d5576c4cc29cfb991d63a1e4f77dd473137bc044a0", dce_ast = "d0248ad1b4f8df9edea988d5576c4cc29cfb991d63a1e4f77dd473137bc044a0", bytecode = """ program test.aleo; struct bar: diff --git a/tests/expectations/compiler/array/nested_array_sum_fail.out b/tests/expectations/compiler/array/nested_array_sum_fail.out index 84d1bf3388..1ac4eab89c 100644 --- a/tests/expectations/compiler/array/nested_array_sum_fail.out +++ b/tests/expectations/compiler/array/nested_array_sum_fail.out @@ -1,14 +1,9 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372007]: Expected one type from `array`, but got `u32` +Error [ETYC0372117]: Expected an array but type `u32` was found. --> compiler-test:9:29 | 9 | sum = sum + a[i][j]; | ^^^^ -Error [ETYC0372003]: Expected type `u32` but type `no type` was found - --> compiler-test:9:23 - | - 9 | sum = sum + a[i][j]; - | ^^^^^^^^^^^^^ """] diff --git a/tests/expectations/compiler/console/assert.out b/tests/expectations/compiler/console/assert.out index 252d8087e7..7d01593787 100644 --- a/tests/expectations/compiler/console/assert.out +++ b/tests/expectations/compiler/console/assert.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "e842df421595b3b67809502efd4090ad62f3a1c381caff3e87fdb0db1d8f05e3", type_checked_symbol_table = "488dfeda4033ab38d660e18201b8374a0afdab04b361438010b4f781d34246b7", unrolled_symbol_table = "488dfeda4033ab38d660e18201b8374a0afdab04b361438010b4f781d34246b7", initial_ast = "6d7ed631427a4ab10f27d2452a1964ad467c76d926d7728a879ecc04dc1cf223", unrolled_ast = "6d7ed631427a4ab10f27d2452a1964ad467c76d926d7728a879ecc04dc1cf223", ssa_ast = "127fc107ad2d3bfd8d45ee0776aa87d5ceb98ea74021834e0a2be91b3aabc2ab", flattened_ast = "384b9c3dc0e6dd88220902841f0b60485d5618eb8c294fad74fa50e695354778", destructured_ast = "0df4d5d73bcbbc4eb62ed67c5b14d1b8838ccef0a38617f9bffae87e9e8f61d2", inlined_ast = "0df4d5d73bcbbc4eb62ed67c5b14d1b8838ccef0a38617f9bffae87e9e8f61d2", dce_ast = "0df4d5d73bcbbc4eb62ed67c5b14d1b8838ccef0a38617f9bffae87e9e8f61d2", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "e17724da5359a9d6e484912a5b1b271d48095a19793582f11c8076e2b951598e", type_checked_symbol_table = "0cf479605887957ccbf5b9788ed9e965a677de867e6103c664e10cfd3d20a649", unrolled_symbol_table = "0cf479605887957ccbf5b9788ed9e965a677de867e6103c664e10cfd3d20a649", initial_ast = "ade6a543693f5fa250337f907a2fc60682e91a30041e4429c997a1a64d2a7d21", unrolled_ast = "ade6a543693f5fa250337f907a2fc60682e91a30041e4429c997a1a64d2a7d21", ssa_ast = "205b0e256162ee0f668c8eb126ead3fb6cfe5ab29e078b849510e4618599ed12", flattened_ast = "c20f911f4549bb2640dea1a42c952cf0d72b09c7ea38d85e8ae1cf4782bb218f", destructured_ast = "0e3ddfa4e71ebe6d7f86fa9ea0083973831945dccd0f84debd6f3302cfd724b2", inlined_ast = "0e3ddfa4e71ebe6d7f86fa9ea0083973831945dccd0f84debd6f3302cfd724b2", dce_ast = "0e3ddfa4e71ebe6d7f86fa9ea0083973831945dccd0f84debd6f3302cfd724b2", bytecode = """ program test.aleo; struct Foo: diff --git a/tests/expectations/compiler/constants/block_height_type_fail.out b/tests/expectations/compiler/constants/block_height_type_fail.out index fcb4df4d49..ca2f04e81c 100644 --- a/tests/expectations/compiler/constants/block_height_type_fail.out +++ b/tests/expectations/compiler/constants/block_height_type_fail.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `u64` but type `u32` was found +Error [ETYC0372117]: Expected type `u64` but type `u32` was found. --> compiler-test:5:22 | 5 | let x: u64 = block.height; diff --git a/tests/expectations/compiler/constants/constant_loop_bound_type_mismatch_fail.out b/tests/expectations/compiler/constants/constant_loop_bound_type_mismatch_fail.out index 45076ec730..e1632090c0 100644 --- a/tests/expectations/compiler/constants/constant_loop_bound_type_mismatch_fail.out +++ b/tests/expectations/compiler/constants/constant_loop_bound_type_mismatch_fail.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `u8` but type `u32` was found +Error [ETYC0372117]: Expected type `u8` but type `u32` was found. --> compiler-test:8:22 | 8 | for i: u8 in START..STOP { diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i128.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i128.out index f315c6c5ef..abc5ee89b3 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i128.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i128.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "43b6979d03d85a3d64bfdd50fda155faf201deb4cf96b11b4b8f2c17a1185beb", type_checked_symbol_table = "f97ccf5d4b99cf0b05d41ba235ad8681c4126ec0b766186aa710f3d081c702cd", unrolled_symbol_table = "f97ccf5d4b99cf0b05d41ba235ad8681c4126ec0b766186aa710f3d081c702cd", initial_ast = "bf89bff0fb684a62a32bf1b3a3354dc9253672fab0e0458323a6e0ee27a1c43f", unrolled_ast = "bf89bff0fb684a62a32bf1b3a3354dc9253672fab0e0458323a6e0ee27a1c43f", ssa_ast = "f224b430ca2db6b408ac8f72fd96cad85f1644854bf86cd05fe904a2b8a427d4", flattened_ast = "64643c25ca0e537611e5381340feb1754b72e31b0efaf837b8354a491b3a59cc", destructured_ast = "3aabc428bd9afe0b5b9f005287cc0389d1a81603be2f72403f30ed566f0f3611", inlined_ast = "3aabc428bd9afe0b5b9f005287cc0389d1a81603be2f72403f30ed566f0f3611", dce_ast = "e709d068f653888369009929a437ac5b7a424677702dd3ab30e7c3a790e35dfc", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i128; - output r8 as i128.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:49 + | + 27 | let a: i128 = Pedersen128::hash_to_i128(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:49 + | + 29 | let c: i128 = Pedersen128::hash_to_i128(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:49 + | + 30 | let d: i128 = Pedersen128::hash_to_i128(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:49 + | + 39 | let o: i128 = Pedersen128::hash_to_i128(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:49 + | + 41 | let q: i128 = Pedersen128::hash_to_i128(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i16.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i16.out index c3cff320bd..95ac3c9aed 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i16.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i16.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "2176f3c0078136f3c1871f918c1b4caa271a0fcea91ec71cd5b13d0d5047ead1", type_checked_symbol_table = "1f55d2b49bf09bb9c2e703d7ea8f6c10367a7d3f75cd080ae432e1b689a93733", unrolled_symbol_table = "1f55d2b49bf09bb9c2e703d7ea8f6c10367a7d3f75cd080ae432e1b689a93733", initial_ast = "754070a6b34a912393a087cb1ecee4dc66bc7de401cdb54c760ecb28142f9695", unrolled_ast = "754070a6b34a912393a087cb1ecee4dc66bc7de401cdb54c760ecb28142f9695", ssa_ast = "4f04e60538a724a646c28ecd3a3a86991eddbb46e2cbb18b61b1458d631d8d55", flattened_ast = "b2e8226820027ff0af6d9d019db2a33b1d2021233b94794217f1a10d81694b82", destructured_ast = "0810e5a545a3f2e462d1d9156b802b8662cdc7af8da45eda19530cd50aadd003", inlined_ast = "0810e5a545a3f2e462d1d9156b802b8662cdc7af8da45eda19530cd50aadd003", dce_ast = "8c40c47afdd450175dd1e4e97a1a3cdb2bbff66665be52917b3c01cd9cbc1f7a", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i16; - output r8 as i16.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:47 + | + 27 | let a: i16 = Pedersen128::hash_to_i16(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:47 + | + 29 | let c: i16 = Pedersen128::hash_to_i16(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:47 + | + 30 | let d: i16 = Pedersen128::hash_to_i16(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:47 + | + 39 | let o: i16 = Pedersen128::hash_to_i16(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:47 + | + 41 | let q: i16 = Pedersen128::hash_to_i16(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i32.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i32.out index d7e239e9fd..378400a6eb 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i32.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i32.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "1e99433ba7238b2c6fe98b657050b05bdf7379aae0381d7e10022f6740cc5a27", type_checked_symbol_table = "5e70e9482745ef1d94670ad1278ce7d35454e3ea3d9f05c5621a6054ae824a76", unrolled_symbol_table = "5e70e9482745ef1d94670ad1278ce7d35454e3ea3d9f05c5621a6054ae824a76", initial_ast = "8e4c2ea6635cdbe3685626bbc3e94424c6ccb2cc0510867ca5bb3961f480a946", unrolled_ast = "8e4c2ea6635cdbe3685626bbc3e94424c6ccb2cc0510867ca5bb3961f480a946", ssa_ast = "004be176bab45fcf01d53f3c6d8de7156faaca14ea776c89202515caa5f8a319", flattened_ast = "dbbf294838b3ddbd5ce0c2065a1157ba3686a952e6106d68c0eaef7b957e42e5", destructured_ast = "73fddfe650474c5d4a1cd904aa4a423d7333966a428e053132767469b27cbfc1", inlined_ast = "73fddfe650474c5d4a1cd904aa4a423d7333966a428e053132767469b27cbfc1", dce_ast = "6137c54517c2e1dde6404cae9aaef48f89f9c3be11145a93fd80e2d5ec17dc25", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i32; - output r8 as i32.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:47 + | + 27 | let a: i32 = Pedersen128::hash_to_i32(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:47 + | + 29 | let c: i32 = Pedersen128::hash_to_i32(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:47 + | + 30 | let d: i32 = Pedersen128::hash_to_i32(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:47 + | + 39 | let o: i32 = Pedersen128::hash_to_i32(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:47 + | + 41 | let q: i32 = Pedersen128::hash_to_i32(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i64.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i64.out index 8db0fb0cbe..124f7379ba 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i64.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i64.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "947f17aa9f8beb3163cd3c5946744ff5d5d4a4ad87dcf6744c3861d6b51c01c5", type_checked_symbol_table = "46c7d6eace8494858f03955180f6eec58f83de855c82eb01f71eaa2b71a722f2", unrolled_symbol_table = "46c7d6eace8494858f03955180f6eec58f83de855c82eb01f71eaa2b71a722f2", initial_ast = "3735bb203e9ca273c404572cde8f65f5dafdf3127d0f45f91b636fda3a16ee5a", unrolled_ast = "3735bb203e9ca273c404572cde8f65f5dafdf3127d0f45f91b636fda3a16ee5a", ssa_ast = "cf410d2783f4520c99a30748f3e637dba21992480eeb4b27567a038cf6c9e1ee", flattened_ast = "2af214bd1ba25129d91f2e80d0b546dfdfe4a44a3c453b93c845eee262119c53", destructured_ast = "c9634a7746cb2c81283483d04590233dbc4648fdc92d493536553ca029fc4876", inlined_ast = "c9634a7746cb2c81283483d04590233dbc4648fdc92d493536553ca029fc4876", dce_ast = "b62a5e5cfb3987276baa7bd3069ca9af862ef5f1397c72c999065cdb74e845ef", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i64; - output r8 as i64.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:47 + | + 27 | let a: i64 = Pedersen128::hash_to_i64(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:47 + | + 29 | let c: i64 = Pedersen128::hash_to_i64(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:47 + | + 30 | let d: i64 = Pedersen128::hash_to_i64(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:47 + | + 39 | let o: i64 = Pedersen128::hash_to_i64(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:47 + | + 41 | let q: i64 = Pedersen128::hash_to_i64(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i8.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i8.out index 2f5b1028ec..d7f09eff95 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i8.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i8.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "f928b7b8c5cbf510522bcfc86ac93ec3f1701c50d6ad1d07bd149c05948a12c4", type_checked_symbol_table = "71a4f91d8767807eae3af29dab050f20acbc235002f5038d937e1e8b64526ce8", unrolled_symbol_table = "71a4f91d8767807eae3af29dab050f20acbc235002f5038d937e1e8b64526ce8", initial_ast = "18e80b0e0a72563f8016c36827af1d337871834eb676879218adcc6f3e7ee630", unrolled_ast = "18e80b0e0a72563f8016c36827af1d337871834eb676879218adcc6f3e7ee630", ssa_ast = "d19f8da5aad1f750dc672be0d90a3f5e32d2a0619f26cd993609235b12827917", flattened_ast = "1818debae697741abc83767cf15e4263f96c7622b9a639e2a71c4e0b953ccdc5", destructured_ast = "8c175160e9fd3d147862eb026f3391a619989ab26280427813fdf5a464d8e5df", inlined_ast = "8c175160e9fd3d147862eb026f3391a619989ab26280427813fdf5a464d8e5df", dce_ast = "f382b5b36c5f2883a2a145c848396aa2cba58443e79800bdb93a8e58fd0eea14", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i8; - output r8 as i8.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:45 + | + 27 | let a: i8 = Pedersen128::hash_to_i8(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:45 + | + 29 | let c: i8 = Pedersen128::hash_to_i8(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:45 + | + 30 | let d: i8 = Pedersen128::hash_to_i8(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:45 + | + 39 | let o: i8 = Pedersen128::hash_to_i8(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:45 + | + 41 | let q: i8 = Pedersen128::hash_to_i8(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u128.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u128.out index efef5a3f87..91ce444984 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u128.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u128.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "6b312ad86475fdfca881ccc9ccc1062f284e76aa3332675ca143caa7b5d3068b", type_checked_symbol_table = "a2f7f26b368984c3f35b5f4978a773798037cb04cee76da625fdd57037636ce3", unrolled_symbol_table = "a2f7f26b368984c3f35b5f4978a773798037cb04cee76da625fdd57037636ce3", initial_ast = "05388116d75578f3d016e968128eb49ed0fd5d1bac8263a43c0a22586db41be7", unrolled_ast = "05388116d75578f3d016e968128eb49ed0fd5d1bac8263a43c0a22586db41be7", ssa_ast = "cc93c6f8e67a6a8bea57918b876ef9259bfa9510292995ef838cf72357fcb286", flattened_ast = "fe94538f9b1c57cdf57cbc5016304637a36841988c14a5584d2f10d1791ea35d", destructured_ast = "4c0fc38d1c7eae212ccabb17424649c79e1af4a244c89b88d60dd4e705912d53", inlined_ast = "4c0fc38d1c7eae212ccabb17424649c79e1af4a244c89b88d60dd4e705912d53", dce_ast = "e5124a9eb9949bb53b783002e88d78e6ca30f385c922f32f8c12130e010b1d7b", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u128; - output r8 as u128.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:49 + | + 27 | let a: u128 = Pedersen128::hash_to_u128(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:49 + | + 29 | let c: u128 = Pedersen128::hash_to_u128(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:49 + | + 30 | let d: u128 = Pedersen128::hash_to_u128(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:49 + | + 39 | let o: u128 = Pedersen128::hash_to_u128(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:49 + | + 41 | let q: u128 = Pedersen128::hash_to_u128(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u16.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u16.out index c66792930b..12d52ecbf5 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u16.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u16.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "ec7e805453bb4081fba0d721a81e3f15e222fbce2d6e8587c97e24788c164bba", type_checked_symbol_table = "2f1b236449628de012306f999903e6796ada92267f38a4b32b706bfee45521eb", unrolled_symbol_table = "2f1b236449628de012306f999903e6796ada92267f38a4b32b706bfee45521eb", initial_ast = "d76d988d140f3de87ba94168a894b11126294497f96f9ff3eef463eaa902db6c", unrolled_ast = "d76d988d140f3de87ba94168a894b11126294497f96f9ff3eef463eaa902db6c", ssa_ast = "52655895eb79ec997970050f2f57c419973e1010697159020ef42a0ad90f4a62", flattened_ast = "a12499dd93bbe9b2570d2216ef540c2a677c807a22c0e13e7e3b3a3a61215dd1", destructured_ast = "1c041e3e9f86f1abdcad00d081627aaf913d2d4f6581a71d1728aa7003380ad8", inlined_ast = "1c041e3e9f86f1abdcad00d081627aaf913d2d4f6581a71d1728aa7003380ad8", dce_ast = "108d8896374ab5bcdcd6b41f221fdf9f32a4cf483680364d09c9db2cded511c2", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u16; - output r8 as u16.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:47 + | + 27 | let a: u16 = Pedersen128::hash_to_u16(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:47 + | + 29 | let c: u16 = Pedersen128::hash_to_u16(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:47 + | + 30 | let d: u16 = Pedersen128::hash_to_u16(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:47 + | + 39 | let o: u16 = Pedersen128::hash_to_u16(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:47 + | + 41 | let q: u16 = Pedersen128::hash_to_u16(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u32.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u32.out index fb4341c8f4..a1ae529cac 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u32.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u32.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "8e28c7287c2f771e8c1edd2400fd6233cce138d7fb6d42d30d1a9e4b1695331e", type_checked_symbol_table = "7f798834b6576ad6838d62df3ef512cd13bbc1f06c48450ceab20f13c771c21c", unrolled_symbol_table = "7f798834b6576ad6838d62df3ef512cd13bbc1f06c48450ceab20f13c771c21c", initial_ast = "9386d404e9b1afebd4933a1843089ff07d33e2c23dfc9a267e1746d310d1cb39", unrolled_ast = "9386d404e9b1afebd4933a1843089ff07d33e2c23dfc9a267e1746d310d1cb39", ssa_ast = "725877a8ba4243bb9a59be0d09b46072503370c1a0e17268ac8a879147b1c056", flattened_ast = "e6c671e9800d7a1ec145015ef28a1c7074f5e463b52c28cbc1ffdbf57153dde8", destructured_ast = "61b56260ca52c5492058f66cc99d314db0dbd99e9fe92cf075684d5ab226c16a", inlined_ast = "61b56260ca52c5492058f66cc99d314db0dbd99e9fe92cf075684d5ab226c16a", dce_ast = "34aeefa58f2e6c5072f419b81b7939f6e2c5b988e596ab9b30b265628da691d2", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u32; - output r8 as u32.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:47 + | + 27 | let a: u32 = Pedersen128::hash_to_u32(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:47 + | + 29 | let c: u32 = Pedersen128::hash_to_u32(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:47 + | + 30 | let d: u32 = Pedersen128::hash_to_u32(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:47 + | + 39 | let o: u32 = Pedersen128::hash_to_u32(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:47 + | + 41 | let q: u32 = Pedersen128::hash_to_u32(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u64.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u64.out index 41aedab10c..71dd721be1 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u64.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u64.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "a8054d139c44a5920bdea06bd84441aba853f0fa1f2a4d47745d5ad8a4c4882b", type_checked_symbol_table = "4c038d1cef171c789dbdcfe2b71f902e1f302662e235950dd361bf0d94fc39df", unrolled_symbol_table = "4c038d1cef171c789dbdcfe2b71f902e1f302662e235950dd361bf0d94fc39df", initial_ast = "5466fa327019dda719f9a90f7d70818ba08128201bde2507392c89db2e63cf77", unrolled_ast = "5466fa327019dda719f9a90f7d70818ba08128201bde2507392c89db2e63cf77", ssa_ast = "e530058e98d1af2de1ed5b422bbf57e8644307043cae4b46de19d6a07e2b2ef2", flattened_ast = "719126cfaad9b0d8b3343d4eef8ae819c562e3bbc24e478f7ed4f4456c69a27f", destructured_ast = "c597df5325a6ad32b958747e905c5fcaa59d394ef8b55581d98bffeb9f086497", inlined_ast = "c597df5325a6ad32b958747e905c5fcaa59d394ef8b55581d98bffeb9f086497", dce_ast = "dba998d8803882a5fb123211cdd7dec50f6d21781ac98727aef9f43f8f4caf3c", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u64; - output r8 as u64.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:47 + | + 27 | let a: u64 = Pedersen128::hash_to_u64(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:47 + | + 29 | let c: u64 = Pedersen128::hash_to_u64(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:47 + | + 30 | let d: u64 = Pedersen128::hash_to_u64(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:47 + | + 39 | let o: u64 = Pedersen128::hash_to_u64(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:47 + | + 41 | let q: u64 = Pedersen128::hash_to_u64(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u8.out b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u8.out index 54df55e646..c64ebb6f68 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u8.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u8.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "20f182be4d266ff1bdf1f1fd5fdda13dfcd75a35cee0541eb15535abbf46f21f", type_checked_symbol_table = "b4c1f5ff8edadf3cd8fa58bfc3684c17700aff76b9b856b518bbb6c9a25d0bec", unrolled_symbol_table = "b4c1f5ff8edadf3cd8fa58bfc3684c17700aff76b9b856b518bbb6c9a25d0bec", initial_ast = "4be80b510dc6b6be63e6bc8e241b85cf7f0334a95fb6bd6931a08a8c3bb3f74d", unrolled_ast = "4be80b510dc6b6be63e6bc8e241b85cf7f0334a95fb6bd6931a08a8c3bb3f74d", ssa_ast = "5a581e4181f9cacf6d84a9afa7e68cb215d2eb5e12e728e4d2bc7de2e22a05dc", flattened_ast = "e79df3a96d605c9e647f3709b4c97266d4e93b5d8a84fa8d5305b83752e5dee5", destructured_ast = "a6a70f67ab43470b4768192c72cfefd60ac4d03db41632d4c7fd101de8b9b966", inlined_ast = "a6a70f67ab43470b4768192c72cfefd60ac4d03db41632d4c7fd101de8b9b966", dce_ast = "b1edd2bfdabbc088ae1eaccc5861566067d23311b277304136475a6c424c33f6", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u8; - output r8 as u8.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:27:45 + | + 27 | let a: u8 = Pedersen128::hash_to_u8(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:29:45 + | + 29 | let c: u8 = Pedersen128::hash_to_u8(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:30:45 + | + 30 | let d: u8 = Pedersen128::hash_to_u8(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:39:45 + | + 39 | let o: u8 = Pedersen128::hash_to_u8(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:41:45 + | + 41 | let q: u8 = Pedersen128::hash_to_u8(Foo { a: 1u32, b: 1u32, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i128.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i128.out index 190f498631..d991db8b75 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i128.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i128.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "0c5b23dfab60e1ea588e518e970d654f16b816943855029ffa265dafc3125bec", type_checked_symbol_table = "cd7464387f4fd78f7686103cbe80b1f8f8a78001e2e2bc4f2c814705a0b52254", unrolled_symbol_table = "cd7464387f4fd78f7686103cbe80b1f8f8a78001e2e2bc4f2c814705a0b52254", initial_ast = "68b9f7f7c7504a5a51fb683e227ed5769df2439679ea4324108dc4b18d7c6cd2", unrolled_ast = "68b9f7f7c7504a5a51fb683e227ed5769df2439679ea4324108dc4b18d7c6cd2", ssa_ast = "58b46f2474a10a9d8bdbc5cd7e815cb38186eaa35b4e73274e20ec2dc4db47e7", flattened_ast = "d5521383435bd6481ff51653a229976b1e40f2d52d2c11823a9966f01b62d97c", destructured_ast = "5528f2a23916979926e4d1e14599a37570535a8daf6f568d662f9bc056e9a387", inlined_ast = "5528f2a23916979926e4d1e14599a37570535a8daf6f568d662f9bc056e9a387", dce_ast = "6267df234f78df6ee75de1ed19441b3f05521e77fe62986381416aa9b05bcb90", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i128; - output r8 as i128.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:48 + | + 29 | let a: i128 = Pedersen64::hash_to_i128(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:48 + | + 31 | let c: i128 = Pedersen64::hash_to_i128(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:48 + | + 32 | let d: i128 = Pedersen64::hash_to_i128(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:48 + | + 39 | let o: i128 = Pedersen64::hash_to_i128(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:48 + | + 41 | let q: i128 = Pedersen64::hash_to_i128(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i16.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i16.out index 124fef6ca7..f753a2afcd 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i16.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i16.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "712ba2278b119b64cfda40f3e0eb988c30b803432d4857c5ffdc88eda2303a40", type_checked_symbol_table = "6881179a2e2fe76b54fe110627d985276a181d6723a11feb6a4ac4aa501d2be9", unrolled_symbol_table = "6881179a2e2fe76b54fe110627d985276a181d6723a11feb6a4ac4aa501d2be9", initial_ast = "b7a33b4b8154c034fdd645162dcb6e0970b43207e4da38eab90e325b1da20893", unrolled_ast = "b7a33b4b8154c034fdd645162dcb6e0970b43207e4da38eab90e325b1da20893", ssa_ast = "e4ba82a7e85f5e293a87cd4f6dc978e0cfe460791a42252b4fe8b5e6108c0792", flattened_ast = "618f18bb008dc9e7a1775b088abd462d62fbf099cc74be75b8f4a4718fbe2e3d", destructured_ast = "676f2f48de7da29b8ddfc66e8ab829a0a8973f192b8b26734f2038ce0d1d76f1", inlined_ast = "676f2f48de7da29b8ddfc66e8ab829a0a8973f192b8b26734f2038ce0d1d76f1", dce_ast = "4252e8af29756f33f2b931a7734a26e045a2a7446d30a2410846da2828b3d8ba", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i16; - output r8 as i16.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:46 + | + 29 | let a: i16 = Pedersen64::hash_to_i16(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:46 + | + 31 | let c: i16 = Pedersen64::hash_to_i16(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:46 + | + 32 | let d: i16 = Pedersen64::hash_to_i16(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:46 + | + 39 | let o: i16 = Pedersen64::hash_to_i16(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:46 + | + 41 | let q: i16 = Pedersen64::hash_to_i16(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i32.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i32.out index fc458cd7a2..b0a6cafc12 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i32.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i32.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "160fba5cf2ab145e968fd94b3b699e4da872d7bc093de37d3bdf1d66e8c187ef", type_checked_symbol_table = "fca54dd10fdb2a5e761c768875018817c27be11f5bff68255d785f5cbd23ace0", unrolled_symbol_table = "fca54dd10fdb2a5e761c768875018817c27be11f5bff68255d785f5cbd23ace0", initial_ast = "c7ad27e068f9e31d5f4a579b6aae9a4d7d5098d31ec335c2a7df6cf2a88b6d5c", unrolled_ast = "c7ad27e068f9e31d5f4a579b6aae9a4d7d5098d31ec335c2a7df6cf2a88b6d5c", ssa_ast = "a88f3e17618f04390f496477a9f667cedcf7f1923e43c2e71c17c6640d0fc48f", flattened_ast = "74d7b2d2a23070867422c1c542ef45c18682d94eaba6d93382c666b4881faada", destructured_ast = "7b778c1b7c677f31a3bb48eabebe3312dc6a3efbb99a90aa8006a720054c5b15", inlined_ast = "7b778c1b7c677f31a3bb48eabebe3312dc6a3efbb99a90aa8006a720054c5b15", dce_ast = "1fd3566375218e2f0752e38f20dc92185e8b0d95791028b08258d1c1c68d9f32", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i32; - output r8 as i32.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:46 + | + 29 | let a: i32 = Pedersen64::hash_to_i32(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:46 + | + 31 | let c: i32 = Pedersen64::hash_to_i32(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:46 + | + 32 | let d: i32 = Pedersen64::hash_to_i32(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:46 + | + 39 | let o: i32 = Pedersen64::hash_to_i32(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:46 + | + 41 | let q: i32 = Pedersen64::hash_to_i32(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i64.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i64.out index d65d9b52d7..d198a31305 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i64.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i64.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "96e81fd4c194ddc247c52899ce8785ec57e233d1beb5f9949f6e79c1cab5ae76", type_checked_symbol_table = "d9a929c37775603ba7039f3a4d536f75a9fd4add3db733f7dfbda624a6de95c0", unrolled_symbol_table = "d9a929c37775603ba7039f3a4d536f75a9fd4add3db733f7dfbda624a6de95c0", initial_ast = "14a2dc75fbbd456eb8aed9185b0b166b7e5c6db5bd05ff91edeb9c1d5dcae9dc", unrolled_ast = "14a2dc75fbbd456eb8aed9185b0b166b7e5c6db5bd05ff91edeb9c1d5dcae9dc", ssa_ast = "9d16694a286c20a02555f3bc39ba63bd615180b00fd172abb8077e7d73cd4610", flattened_ast = "280eca5d5f54e0e3adb7fd51e9604108ae4575ed083c21d9409bbc7a3f005846", destructured_ast = "321f45f8943a77ecfa454af6bc3bbd0882dc68b239e50deb3894b5b8278244cc", inlined_ast = "321f45f8943a77ecfa454af6bc3bbd0882dc68b239e50deb3894b5b8278244cc", dce_ast = "8908de64f7b09842b4177903a2623a2df445c481b20786e9a6b1989245e1a841", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i64; - output r8 as i64.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:46 + | + 29 | let a: i64 = Pedersen64::hash_to_i64(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:46 + | + 31 | let c: i64 = Pedersen64::hash_to_i64(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:46 + | + 32 | let d: i64 = Pedersen64::hash_to_i64(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:46 + | + 39 | let o: i64 = Pedersen64::hash_to_i64(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:46 + | + 41 | let q: i64 = Pedersen64::hash_to_i64(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i8.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i8.out index 0e0f9e0cd5..bed8147146 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i8.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i8.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "ecb2c47dc7c6c121aa3383391698c7ad177f04fb1863e0fdc12cc6272bcfa972", type_checked_symbol_table = "0d87e7eab46179728a33c0197bafbc8830a1a09a954727ea0ec3e81427d11b0c", unrolled_symbol_table = "0d87e7eab46179728a33c0197bafbc8830a1a09a954727ea0ec3e81427d11b0c", initial_ast = "a0a6882a0c110b02294679038c0728142b2413ca33f110937d141f39a6b3e64e", unrolled_ast = "a0a6882a0c110b02294679038c0728142b2413ca33f110937d141f39a6b3e64e", ssa_ast = "e5e108ab23b2309e77f5e34b577e704f5f6de9900931c42582fbfb9b50960f5b", flattened_ast = "9295d88ec186d91cba26b0e4d19f1a38d644261d02b624c6ad2e3a7f3e4f3784", destructured_ast = "c8ff85f5aa4c8d600aff2669e39aa9a6097be4444561a804e134745075228fb2", inlined_ast = "c8ff85f5aa4c8d600aff2669e39aa9a6097be4444561a804e134745075228fb2", dce_ast = "6847b17428596f24a3b5c6b27bf1037bb126647df1a0a1fd1d7d31e54fb6bfd1", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as i8; - output r8 as i8.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:27:44 + | + 27 | let a: i8 = Pedersen64::hash_to_i8(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:29:44 + | + 29 | let c: i8 = Pedersen64::hash_to_i8(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:30:44 + | + 30 | let d: i8 = Pedersen64::hash_to_i8(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:37:44 + | + 37 | let o: i8 = Pedersen64::hash_to_i8(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:39:44 + | + 39 | let q: i8 = Pedersen64::hash_to_i8(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u128.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u128.out index f049f816f6..d8cb906769 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u128.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u128.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "ad0c0ba49666fa9b8741106d20a60e91acd6b76cbd911976d44d990db0cb074c", type_checked_symbol_table = "0d6e6ebdc71177f59174521dc874bb2baea5abd1de4eb2cc5f5f51c08877b594", unrolled_symbol_table = "0d6e6ebdc71177f59174521dc874bb2baea5abd1de4eb2cc5f5f51c08877b594", initial_ast = "ffee7d6c150ab1b54dad107f403680324f0aee75bd2a6e0812fce86aa46f2ee2", unrolled_ast = "ffee7d6c150ab1b54dad107f403680324f0aee75bd2a6e0812fce86aa46f2ee2", ssa_ast = "1406465f29612891e3d2ee446437d8809e412aa1b643ce3ce12359e44f82d610", flattened_ast = "032582d117a7e49add220191298ee8d6c4027e245d0c1992cbcf29972c2f4374", destructured_ast = "792843993ceb51b78affe1fc51876fb06743c164cff7e0a553edf4558252caca", inlined_ast = "792843993ceb51b78affe1fc51876fb06743c164cff7e0a553edf4558252caca", dce_ast = "94acf91a3041826e5614166c0ee4c8bede2eb37bd5dbffdb275d4b47e35aaaae", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u128; - output r8 as u128.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:48 + | + 29 | let a: u128 = Pedersen64::hash_to_u128(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:48 + | + 31 | let c: u128 = Pedersen64::hash_to_u128(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:48 + | + 32 | let d: u128 = Pedersen64::hash_to_u128(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:48 + | + 39 | let o: u128 = Pedersen64::hash_to_u128(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:48 + | + 41 | let q: u128 = Pedersen64::hash_to_u128(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u16.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u16.out index 2e16805fc3..1348586a2b 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u16.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u16.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "9333d02fedbf611192b8ac7603d6cd75a5547610205440f01df034c7f1429266", type_checked_symbol_table = "bb92631c8360eff0d8a11ceeebe545d184e0f24e57f4e03ef4a33efa6183e3f8", unrolled_symbol_table = "bb92631c8360eff0d8a11ceeebe545d184e0f24e57f4e03ef4a33efa6183e3f8", initial_ast = "23f1cfeb5ded0a386597ac1ed019ff7906d3bf31c2124f5aa0c6b6289a1fedd7", unrolled_ast = "23f1cfeb5ded0a386597ac1ed019ff7906d3bf31c2124f5aa0c6b6289a1fedd7", ssa_ast = "67e881b8a0c853ab46b3bdbda543e99a9047b59ac03cc59656109e7e08bf3fc4", flattened_ast = "27cea8d4bbd11b33c828a7241c31dd8990424b825e3fb73bb99f297f1cc04f66", destructured_ast = "8030b6ae11db9610277d3630c3d5a54889028a6b99385ff9e3c39f665d894731", inlined_ast = "8030b6ae11db9610277d3630c3d5a54889028a6b99385ff9e3c39f665d894731", dce_ast = "967aac06caf5b7e8aa98f98ad764c6a029105235205558c26db189d81dace023", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u16; - output r8 as u16.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:46 + | + 29 | let a: u16 = Pedersen64::hash_to_u16(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:46 + | + 31 | let c: u16 = Pedersen64::hash_to_u16(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:46 + | + 32 | let d: u16 = Pedersen64::hash_to_u16(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:46 + | + 39 | let o: u16 = Pedersen64::hash_to_u16(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:46 + | + 41 | let q: u16 = Pedersen64::hash_to_u16(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u32.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u32.out index 50d95fd273..20c9424e14 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u32.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u32.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "bcbb74fefed2f406308cad56c692eb6abeb05b2c8714503cc548e3d85857f712", type_checked_symbol_table = "304037e017528b1b031d58b47acd0cf49845bf519d3f92a6d30db7853bc03307", unrolled_symbol_table = "304037e017528b1b031d58b47acd0cf49845bf519d3f92a6d30db7853bc03307", initial_ast = "29fb669950c75c3e68357cd07ade8e2f4da77b74db137b78e8a9164290f33f40", unrolled_ast = "29fb669950c75c3e68357cd07ade8e2f4da77b74db137b78e8a9164290f33f40", ssa_ast = "7ae7464f03756218449e0fef6f0865578b52b3eec881d439cdb4ed787e2aee94", flattened_ast = "e54a4424efebf9e6aa2665507232d7c148e49e5b786c926c26ea573743b3b9ee", destructured_ast = "23a092f35286253af0b458ec6fc5fc4a1417b4c0a9064cc477dc5098ab737722", inlined_ast = "23a092f35286253af0b458ec6fc5fc4a1417b4c0a9064cc477dc5098ab737722", dce_ast = "913294ec9edf1c3776dc99b283f8be4b14e8d47e60a45b3357e0e8df1c7943bc", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u32; - output r8 as u32.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:46 + | + 29 | let a: u32 = Pedersen64::hash_to_u32(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:46 + | + 31 | let c: u32 = Pedersen64::hash_to_u32(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:46 + | + 32 | let d: u32 = Pedersen64::hash_to_u32(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:46 + | + 39 | let o: u32 = Pedersen64::hash_to_u32(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:46 + | + 41 | let q: u32 = Pedersen64::hash_to_u32(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u64.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u64.out index 2806322f9c..bc941065c4 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u64.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u64.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "0cfd8b0cb21561fb7554996f3edbc883fc170dace49d5f0839bb52b8d7800d19", type_checked_symbol_table = "5f0c9faa2523b7bf3a0c25bfc4431ca84519d9146dce75f01c7fda74d43f02b4", unrolled_symbol_table = "5f0c9faa2523b7bf3a0c25bfc4431ca84519d9146dce75f01c7fda74d43f02b4", initial_ast = "a16e9c1f4ea1aa8d80c0c3b4599597a8795bd8408b00b79bf5a5ba80849bf701", unrolled_ast = "a16e9c1f4ea1aa8d80c0c3b4599597a8795bd8408b00b79bf5a5ba80849bf701", ssa_ast = "8df24f8bba330d3d907673277d830b30ef7469cbe7dc29d11c62a36dd800d192", flattened_ast = "c0ca1ea2f49dfb3ad0812db589a62518d29a799548fef7de5d43792a498bfa12", destructured_ast = "42bfa93bd57da697e33233e8d60344b98a49563f3528efdf15c08e1885548973", inlined_ast = "42bfa93bd57da697e33233e8d60344b98a49563f3528efdf15c08e1885548973", dce_ast = "43f0df4f48ceaf766aeb542dc4b610c79b041dfba2b7158b537674a671bd1400", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u64; - output r8 as u64.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:46 + | + 29 | let a: u64 = Pedersen64::hash_to_u64(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:46 + | + 31 | let c: u64 = Pedersen64::hash_to_u64(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:46 + | + 32 | let d: u64 = Pedersen64::hash_to_u64(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:46 + | + 39 | let o: u64 = Pedersen64::hash_to_u64(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:46 + | + 41 | let q: u64 = Pedersen64::hash_to_u64(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u8.out b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u8.out index 2e175b1072..38030fcaa9 100644 --- a/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u8.out +++ b/tests/expectations/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u8.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "2ef869c3e63096f9847e1eb6f4914d54e9cf70ea62b02c077b94cdbd859bb16d", type_checked_symbol_table = "6c9e2246215d533a3b51a7fbb9c81c4572ddc2a6541386fc7507a832aaaa7150", unrolled_symbol_table = "6c9e2246215d533a3b51a7fbb9c81c4572ddc2a6541386fc7507a832aaaa7150", initial_ast = "1676293a5dce7cf02649a2ecedf739a5600e095c4f5797ee3a559451e153bc72", unrolled_ast = "1676293a5dce7cf02649a2ecedf739a5600e095c4f5797ee3a559451e153bc72", ssa_ast = "80f867e3c82165605b9b12c842564a0c8cf3de4e8782f22f4c8296b7ef9ea390", flattened_ast = "d15bfbfe5556102d82fc1a34957c23f8a5cf646594c2f2c31aba5c8211b13997", destructured_ast = "06614749740fb6275ee9779f480d8e1f9e03950894011d7d15c522ac029610ab", inlined_ast = "06614749740fb6275ee9779f480d8e1f9e03950894011d7d15c522ac029610ab", dce_ast = "9ce604662c2090fe91e2188565507603189b55c80c02c839abb4231c51cc44a0", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as u8; - output r8 as u8.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:29:44 + | + 29 | let a: u8 = Pedersen64::hash_to_u8(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:31:44 + | + 31 | let c: u8 = Pedersen64::hash_to_u8(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:32:44 + | + 32 | let d: u8 = Pedersen64::hash_to_u8(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:39:44 + | + 39 | let o: u8 = Pedersen64::hash_to_u8(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:41:44 + | + 41 | let q: u8 = Pedersen64::hash_to_u8(Foo { a: 1u16, b: 1u16, }); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_address.out b/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_address.out index e2b984ea69..2eeb1167ae 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_address.out +++ b/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_address.out @@ -1,23 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "501d55f20d3f1a572c2a5c1bbaeb74c0daf60d60206e00a480f3515a8b317d72", type_checked_symbol_table = "cf18ef0906051a43a21927ca8ab931709985574f7a0c257ed0a3bde10886db41", unrolled_symbol_table = "cf18ef0906051a43a21927ca8ab931709985574f7a0c257ed0a3bde10886db41", initial_ast = "d10b8955d24f0ea00219c01c7b98dca6019e7e470ceee990ed117c7add0cb463", unrolled_ast = "d10b8955d24f0ea00219c01c7b98dca6019e7e470ceee990ed117c7add0cb463", ssa_ast = "5004830327a5db55b58e950850b05b991574c644027dc6ab56484e685e25463e", flattened_ast = "9ef1fd1aa11b35cabc0a6de842e57eef43e50fd69ad24b3d3e7f7678daad7af4", destructured_ast = "b5c766a35043afd037da5869b81c212a8086d13c3c596379c60f605000c4a3a9", inlined_ast = "b5c766a35043afd037da5869b81c212a8086d13c3c596379c60f605000c4a3a9", dce_ast = "3838b540951a48634c3c008076e9ab64017ad6cc5cf022d30bbf75f590b47b12", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - commit.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta 1scalar into r8 as address; - commit.ped128 r4 1scalar into r9 as address; - is.eq r8 r9 into r10; - output r10 as boolean.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:29:57 + | + 29 | let a: address = Pedersen128::commit_to_address(addr_value, scalar_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:31:57 + | + 31 | let c: address = Pedersen128::commit_to_address(field_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:32:57 + | + 32 | let d: address = Pedersen128::commit_to_address(group_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:41:57 + | + 41 | let o: address = Pedersen128::commit_to_address(scalar_value, scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:43:57 + | + 43 | let p: address = Pedersen128::commit_to_address(Foo { a: 1u32, b: 1u32 }, scalar_value); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_field.out b/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_field.out index 0aee75c193..2682c15f63 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_field.out +++ b/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_field.out @@ -1,23 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "501d55f20d3f1a572c2a5c1bbaeb74c0daf60d60206e00a480f3515a8b317d72", type_checked_symbol_table = "db0f89fb855e13d2099b675fb8bdcd27ba69a43b194a757953cdafa5e0a3c089", unrolled_symbol_table = "db0f89fb855e13d2099b675fb8bdcd27ba69a43b194a757953cdafa5e0a3c089", initial_ast = "2c74e033d97e0550d5f3e7f8919abf3b1be853d3a026689e18a27f4e4c8f7100", unrolled_ast = "2c74e033d97e0550d5f3e7f8919abf3b1be853d3a026689e18a27f4e4c8f7100", ssa_ast = "0cb8161b427eac17a3f7d07d3a255eb874b0a81b1ff9efe5c841d8cc6ebeddd8", flattened_ast = "91e4a5bc4a66cff29a030e463aa749d2fc8739ca7e1f743de288efdf8652d031", destructured_ast = "1e4f728da69529a555a7ebb82d4b6aa440c85b53d2f412fc09f7bcff0bf6a303", inlined_ast = "1e4f728da69529a555a7ebb82d4b6aa440c85b53d2f412fc09f7bcff0bf6a303", dce_ast = "258e64b46de98d4d07352e03e6c5053dc7cbc7cc5f3db4dab5894b62c003a911", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - commit.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta 1scalar into r8 as field; - commit.ped128 r4 1scalar into r9 as field; - is.eq r8 r9 into r10; - output r10 as boolean.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:29:53 + | + 29 | let a: field = Pedersen128::commit_to_field(addr_value, scalar_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:31:53 + | + 31 | let c: field = Pedersen128::commit_to_field(field_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:32:53 + | + 32 | let d: field = Pedersen128::commit_to_field(group_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:41:53 + | + 41 | let o: field = Pedersen128::commit_to_field(scalar_value, scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:43:53 + | + 43 | let p: field = Pedersen128::commit_to_field(Foo { a: 1u32, b: 1u32 }, scalar_value); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_group.out b/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_group.out index e2f8e2fda3..ab992af737 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_group.out +++ b/tests/expectations/compiler/core/algorithms/pedersen128_commit_to_group.out @@ -1,23 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "501d55f20d3f1a572c2a5c1bbaeb74c0daf60d60206e00a480f3515a8b317d72", type_checked_symbol_table = "1aa442be13d523c657fc34987bda9b954d70ce031810252ecd4bcf113fbc7fce", unrolled_symbol_table = "1aa442be13d523c657fc34987bda9b954d70ce031810252ecd4bcf113fbc7fce", initial_ast = "fcd43cf43733b1c80e5ae0ac563bdda3b99b39e2658d7bf18543b69bc0f31587", unrolled_ast = "fcd43cf43733b1c80e5ae0ac563bdda3b99b39e2658d7bf18543b69bc0f31587", ssa_ast = "a3dae9e52567781081f49837c75b13719fbe1fc46f67cce47094b62503d99dac", flattened_ast = "ebb0770add34a77d532c129bc5fee8bc74437ea5defe6d34ff13fa5f52c35b35", destructured_ast = "cefcad555acdf4f13571984d63bf82ac0d766578951034aee7e12ba3c22a0239", inlined_ast = "cefcad555acdf4f13571984d63bf82ac0d766578951034aee7e12ba3c22a0239", dce_ast = "77e21e5096a1ec4f19060b73c42142a29dfca584ac2f89fe8e1750b4f0c55193", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - commit.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta 1scalar into r8 as group; - commit.ped128 r4 1scalar into r9 as group; - is.eq r8 r9 into r10; - output r10 as boolean.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:29:53 + | + 29 | let a: group = Pedersen128::commit_to_group(addr_value, scalar_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:31:53 + | + 31 | let c: group = Pedersen128::commit_to_group(field_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:32:53 + | + 32 | let d: group = Pedersen128::commit_to_group(group_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:41:53 + | + 41 | let o: group = Pedersen128::commit_to_group(scalar_value, scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:43:53 + | + 43 | let p: group = Pedersen128::commit_to_group(Foo { a: 1u32, b: 1u32 }, scalar_value); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_address.out b/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_address.out index cec4cbdb49..f5328aa7e5 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_address.out +++ b/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_address.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "9a9ce539c5db1390d701f8f9cce7591f1aadb958544c76640332f89dc4871818", type_checked_symbol_table = "9e0c93b497a4e4ea4adb478df544aacf04b210ca3be8448127a19746517fd4f0", unrolled_symbol_table = "9e0c93b497a4e4ea4adb478df544aacf04b210ca3be8448127a19746517fd4f0", initial_ast = "2887a87b28ce882ef5eb92729940e91f3eab8a2f5efb96eefe325be750373b1d", unrolled_ast = "2887a87b28ce882ef5eb92729940e91f3eab8a2f5efb96eefe325be750373b1d", ssa_ast = "fb7dca997fec396d9a20feda66d5a292d7ba39a11e9de8f5bf86843ad608720b", flattened_ast = "48c35557707bcfce348e1acef81c87bccd7f79bcd01d03c36438070bfb5bd755", destructured_ast = "86c4c74fa0be1fff02c706d16c646cb412733cc3617c3d353290d409479a20f1", inlined_ast = "86c4c74fa0be1fff02c706d16c646cb412733cc3617c3d353290d409479a20f1", dce_ast = "0afa089fff57677dc8ed2d4ae6f86797bc100b7a424fbc50964ce7c53b372e31", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as address; - output r8 as address.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:29:55 + | + 29 | let a: address = Pedersen128::hash_to_address(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:31:55 + | + 31 | let c: address = Pedersen128::hash_to_address(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:32:55 + | + 32 | let d: address = Pedersen128::hash_to_address(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:41:55 + | + 41 | let o: address = Pedersen128::hash_to_address(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:43:55 + | + 43 | let p: address = Pedersen128::hash_to_address(Foo { a: 1u32, b: 1u32 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_field.out b/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_field.out index bc4daaea04..a351773708 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_field.out +++ b/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_field.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "b35030986eebd8b0f4055bf0de55fcacad27b202140cd222e80e5a5fcf3b27d1", type_checked_symbol_table = "8e04c85b3774cd9fb55d3811d31a6994e1b3e104c6bd7d5d3ccea9118c44c4d0", unrolled_symbol_table = "8e04c85b3774cd9fb55d3811d31a6994e1b3e104c6bd7d5d3ccea9118c44c4d0", initial_ast = "0c91a79da594ce1ad93542859de7a531eec81fe516abea9d3f0713c341dd1529", unrolled_ast = "0c91a79da594ce1ad93542859de7a531eec81fe516abea9d3f0713c341dd1529", ssa_ast = "7dedeb6948a89d9f6bca8c8ddd098fbe96907ae54bb3856e8a06b41f82c0d5ba", flattened_ast = "8f0b6d487d54ee8eb8c294245dea631b9954c21970e64fe7fb30efb238ed5bd0", destructured_ast = "8944cb65be76a42e79525eebbe2dbbbe8095b6add0b3aaa228d280e0b7f3c7b5", inlined_ast = "8944cb65be76a42e79525eebbe2dbbbe8095b6add0b3aaa228d280e0b7f3c7b5", dce_ast = "3f0e9fd891a8f845d5c151de786813853aea8977d11005cbc9a8212fb8ec6b16", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as field; - output r8 as field.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:29:51 + | + 29 | let a: field = Pedersen128::hash_to_field(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:31:51 + | + 31 | let c: field = Pedersen128::hash_to_field(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:32:51 + | + 32 | let d: field = Pedersen128::hash_to_field(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:41:51 + | + 41 | let o: field = Pedersen128::hash_to_field(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:43:51 + | + 43 | let p: field = Pedersen128::hash_to_field(Foo { a: 1u32, b: 1u32 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_group.out b/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_group.out index 1fa5d40af3..9dec1f6eb1 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_group.out +++ b/tests/expectations/compiler/core/algorithms/pedersen128_hash_to_group.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "cf8f80111fec71cb16c98d580e6efeaed5f641ea2361ff82b16c2640fb48b69e", type_checked_symbol_table = "163f2c1b2f4e2fe77e6ef2c9b03c550c107e4b73a64cc83f98c9ba08b435f154", unrolled_symbol_table = "163f2c1b2f4e2fe77e6ef2c9b03c550c107e4b73a64cc83f98c9ba08b435f154", initial_ast = "1064081f294b843439e010fb00822250d8f6f6f1410540cd2c72cf5a3f2c156d", unrolled_ast = "1064081f294b843439e010fb00822250d8f6f6f1410540cd2c72cf5a3f2c156d", ssa_ast = "33a5335359ab9b7c4fcba04f8bfd298a8d79fba379ad48ec1b872bfc09246a3a", flattened_ast = "48e7c30f14e8a9b5101c86462e567f4f1e1db508cb9dd6ba6396cacd8e7f8749", destructured_ast = "3075ceb16742cc16565713e2f31c27b1cc0b8331e409d6324dfdc2e8aaf4e8fc", inlined_ast = "3075ceb16742cc16565713e2f31c27b1cc0b8331e409d6324dfdc2e8aaf4e8fc", dce_ast = "56a45ef1487fbf9edd3bc29a3bdb35c3bb819cfbea63ad06d94f279b38852839", bytecode = """ -program test.aleo; - -struct Foo: - a as u32; - b as u32; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped128 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as group; - output r8 as group.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `address` was found. + --> compiler-test:29:51 + | + 29 | let a: group = Pedersen128::hash_to_group(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `field` was found. + --> compiler-test:31:51 + | + 31 | let c: group = Pedersen128::hash_to_group(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `group` was found. + --> compiler-test:32:51 + | + 32 | let d: group = Pedersen128::hash_to_group(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `scalar` was found. + --> compiler-test:41:51 + | + 41 | let o: group = Pedersen128::hash_to_group(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 128 bits or a bool but type `Foo` was found. + --> compiler-test:43:51 + | + 43 | let p: group = Pedersen128::hash_to_group(Foo { a: 1u32, b: 1u32 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_address.out b/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_address.out index 1406c9150c..940b17bbb3 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_address.out +++ b/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_address.out @@ -1,23 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "98f0b93406bc0ab5d755fb4d4da966be418df82f4a376f328dad3769a95db3eb", type_checked_symbol_table = "11054f75a159ca0743eacced1983df41112cec5fdf165580c515cb3b1bb7be49", unrolled_symbol_table = "11054f75a159ca0743eacced1983df41112cec5fdf165580c515cb3b1bb7be49", initial_ast = "0eafa3b3da0309e63d52b02abb716e3f7eb9783b84e483d423f25e80cc35c5ef", unrolled_ast = "0eafa3b3da0309e63d52b02abb716e3f7eb9783b84e483d423f25e80cc35c5ef", ssa_ast = "f114c8496fb38b819ca571cdff6b0445107372c294060da5cc4bedb0d23ca6b0", flattened_ast = "72c434f620c87913414ae76719411c02a0f05adfd01465c8718cc3606c1478cf", destructured_ast = "a98b315b4994e3b9c1d2ec0f56c0cb7e838f16ebc923516e72d6d5bdb05ffb2c", inlined_ast = "a98b315b4994e3b9c1d2ec0f56c0cb7e838f16ebc923516e72d6d5bdb05ffb2c", dce_ast = "d09def911096b772d6b27b93a98f359eb337ae58879a659d2d34437f0c0a13b2", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - commit.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta 1scalar into r8 as address; - commit.ped64 r4 1scalar into r9 as address; - is.eq r8 r9 into r10; - output r10 as boolean.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:27:56 + | + 27 | let a: address = Pedersen64::commit_to_address(addr_value, scalar_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:29:56 + | + 29 | let c: address = Pedersen64::commit_to_address(field_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:30:56 + | + 30 | let d: address = Pedersen64::commit_to_address(group_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:37:56 + | + 37 | let m: address = Pedersen64::commit_to_address(scalar_value, scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:39:56 + | + 39 | let n: address = Pedersen64::commit_to_address(Foo { a: 1u16, b: 1u16 }, scalar_value); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_field.out b/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_field.out index 62a8efe98a..27ed43120b 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_field.out +++ b/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_field.out @@ -1,23 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "98f0b93406bc0ab5d755fb4d4da966be418df82f4a376f328dad3769a95db3eb", type_checked_symbol_table = "19fdc82ac5ff496005c573c64ba8a023dd017a7d4447d3779cede32f34559b39", unrolled_symbol_table = "19fdc82ac5ff496005c573c64ba8a023dd017a7d4447d3779cede32f34559b39", initial_ast = "90b835d4281bd7caf76cd9cb3e0e351e873618c31dbdbe7e0e68a54b964a437e", unrolled_ast = "90b835d4281bd7caf76cd9cb3e0e351e873618c31dbdbe7e0e68a54b964a437e", ssa_ast = "2698b5c4b8aefce178266aa6ff04a96ef1a8fde0cd76e0a1c7797c519a61271f", flattened_ast = "420e05f69ec8f5f36bd0610e53205edb50f724824c9c99ab74ee89cef03d8bc5", destructured_ast = "8cb8388a9d032f0e41d9fc497dd53a806b4cbf3dd8b2a2f76fad9bebad617848", inlined_ast = "8cb8388a9d032f0e41d9fc497dd53a806b4cbf3dd8b2a2f76fad9bebad617848", dce_ast = "7aeb4ca69132188ebcc3ddefbd593988585d4011c26dcfd61d4e2cd9368bfcbd", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - commit.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta 1scalar into r8 as field; - commit.ped64 r4 1scalar into r9 as field; - is.eq r8 r9 into r10; - output r10 as boolean.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:27:52 + | + 27 | let a: field = Pedersen64::commit_to_field(addr_value, scalar_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:29:52 + | + 29 | let c: field = Pedersen64::commit_to_field(field_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:30:52 + | + 30 | let d: field = Pedersen64::commit_to_field(group_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:37:52 + | + 37 | let m: field = Pedersen64::commit_to_field(scalar_value, scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:39:52 + | + 39 | let n: field = Pedersen64::commit_to_field(Foo { a: 1u16, b: 1u16 }, scalar_value); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_group.out b/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_group.out index 7a61bfae3f..c1932f2031 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_group.out +++ b/tests/expectations/compiler/core/algorithms/pedersen64_commit_to_group.out @@ -1,23 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "98f0b93406bc0ab5d755fb4d4da966be418df82f4a376f328dad3769a95db3eb", type_checked_symbol_table = "36395772cc753c8445b1891d3eca79be770019b5f9be35dec15c4daa437dd0fb", unrolled_symbol_table = "36395772cc753c8445b1891d3eca79be770019b5f9be35dec15c4daa437dd0fb", initial_ast = "594a14284059b421b9b836a46a0063c3ad6a992364dc05add652eb226fbe2a07", unrolled_ast = "594a14284059b421b9b836a46a0063c3ad6a992364dc05add652eb226fbe2a07", ssa_ast = "ede6f692866dadf3e2b5de89cce9479e661e4f2a35cb510e5d57e17537577ac6", flattened_ast = "37187dc61d74852dad5ed54df704e576960cf81c259cd94ce14c1bcd5d4081a2", destructured_ast = "43a99b40ee568b1cfac907cc4205d60ec74ef59ddd68553402d4a652de22f5f2", inlined_ast = "43a99b40ee568b1cfac907cc4205d60ec74ef59ddd68553402d4a652de22f5f2", dce_ast = "226dff47c2f977b5a88781f5f41ad9e0fb73b805c7de2477c1773d85ea895ccb", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - commit.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta 1scalar into r8 as group; - commit.ped64 r4 1scalar into r9 as group; - is.eq r8 r9 into r10; - output r10 as boolean.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:27:52 + | + 27 | let a: group = Pedersen64::commit_to_group(addr_value, scalar_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:29:52 + | + 29 | let c: group = Pedersen64::commit_to_group(field_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:30:52 + | + 30 | let d: group = Pedersen64::commit_to_group(group_value, scalar_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:37:52 + | + 37 | let m: group = Pedersen64::commit_to_group(scalar_value, scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:39:52 + | + 39 | let n: group = Pedersen64::commit_to_group(Foo { a: 1u16, b: 1u16 }, scalar_value); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_address.out b/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_address.out index 592e54439b..cda5d3f2bc 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_address.out +++ b/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_address.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "f5a5776350ce988c849ddfd1aeb1007326534cabeeb69d8067d0896254bea044", type_checked_symbol_table = "78c54cb0462f628ab9c405f80e6c7fb1ed97e40cb058848de5c8db24607a826b", unrolled_symbol_table = "78c54cb0462f628ab9c405f80e6c7fb1ed97e40cb058848de5c8db24607a826b", initial_ast = "99073126c73dd8a427a183ff2c8d249141f93b0be0202e08ea13a37756c2c1d3", unrolled_ast = "99073126c73dd8a427a183ff2c8d249141f93b0be0202e08ea13a37756c2c1d3", ssa_ast = "251491d86d9f06ff7f36c76bf5e29140075b89729dac0e0c1f1db23e63ac4897", flattened_ast = "786f3f8d419330faae2e10fe6452d9f86a3befbd3323fec82f03323be98fc86c", destructured_ast = "c99dc2d8428ea9698158d4bba41d497ba5a2b571c1e26ddc4527193a76145808", inlined_ast = "c99dc2d8428ea9698158d4bba41d497ba5a2b571c1e26ddc4527193a76145808", dce_ast = "1073639e1e5bc85e79bbb610de53d6763579b3db3a39c2b3ef24ad0328d80223", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as address; - output r8 as address.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:27:54 + | + 27 | let a: address = Pedersen64::hash_to_address(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:29:54 + | + 29 | let c: address = Pedersen64::hash_to_address(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:30:54 + | + 30 | let d: address = Pedersen64::hash_to_address(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:37:54 + | + 37 | let m: address = Pedersen64::hash_to_address(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:39:54 + | + 39 | let n: address = Pedersen64::hash_to_address(Foo { a: 1u16, b: 1u16 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_field.out b/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_field.out index 44bf81be50..741a991452 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_field.out +++ b/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_field.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "56b062bf23a1f61497942aee31138e1720a2317d48413c9eb73b9bfa13a05374", type_checked_symbol_table = "66f651c0e17c985596a76f27e064ad569a16522666a7089f257bad259ace7ffd", unrolled_symbol_table = "66f651c0e17c985596a76f27e064ad569a16522666a7089f257bad259ace7ffd", initial_ast = "125a949338482710e7ca3c35841f673e8464c45ad0c9b88a730fc65c33c63755", unrolled_ast = "125a949338482710e7ca3c35841f673e8464c45ad0c9b88a730fc65c33c63755", ssa_ast = "3fb59f5d060ca06bc791fcce8eb098244780b09de14bfe7dba933dfd27c2668a", flattened_ast = "a8cc36c11a15899f6744515b69fdf643c16669c4a316f46bca325a11b3d33461", destructured_ast = "ca33a64950598312b81a6d1334224a15da96a9fd344f5d922f3daef619cfae88", inlined_ast = "ca33a64950598312b81a6d1334224a15da96a9fd344f5d922f3daef619cfae88", dce_ast = "2eb59567caeb4750790eca44fdf113b0d66a10f1a8868441d5d7d01aa16e15dd", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as field; - output r8 as field.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:27:50 + | + 27 | let a: field = Pedersen64::hash_to_field(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:29:50 + | + 29 | let c: field = Pedersen64::hash_to_field(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:30:50 + | + 30 | let d: field = Pedersen64::hash_to_field(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:37:50 + | + 37 | let m: field = Pedersen64::hash_to_field(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:39:50 + | + 39 | let n: field = Pedersen64::hash_to_field(Foo { a: 1u16, b: 1u16 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_group.out b/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_group.out index 1387ef9904..cacb6a02f0 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_group.out +++ b/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_group.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "2061db24723ed76bf97af34ce45e35f364266c59c8f4ae691707ca2b0ba1a517", type_checked_symbol_table = "2b66182ba431f03b24fc5216c30db08b63717561f4c752e8bc1f0d8a75d08b08", unrolled_symbol_table = "2b66182ba431f03b24fc5216c30db08b63717561f4c752e8bc1f0d8a75d08b08", initial_ast = "d18c2d27b71c443e3b2696aaad60a0fdfbea0ce4aa4f3fe9affef7da1634d4ef", unrolled_ast = "d18c2d27b71c443e3b2696aaad60a0fdfbea0ce4aa4f3fe9affef7da1634d4ef", ssa_ast = "981789579c5f8b63c754976b41f0a746ecfa7f33328acbd9c2c6cb55551e1f8f", flattened_ast = "e418f30466f92b73c05831339977587deb301fb9b7b5605ee50ea608a55b16a2", destructured_ast = "daf3c4d141acbde48ecc278a548e507cd5f50374db66d9d81e3f5bff03d84f74", inlined_ast = "daf3c4d141acbde48ecc278a548e507cd5f50374db66d9d81e3f5bff03d84f74", dce_ast = "15479a266cf6e4ddef14c7aaae33d4dbd84b80a392c070edf963aa63be6c3778", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as group; - output r8 as group.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:27:50 + | + 27 | let a: group = Pedersen64::hash_to_group(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:29:50 + | + 29 | let c: group = Pedersen64::hash_to_group(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:30:50 + | + 30 | let d: group = Pedersen64::hash_to_group(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:37:50 + | + 37 | let m: group = Pedersen64::hash_to_group(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:39:50 + | + 39 | let n: group = Pedersen64::hash_to_group(Foo { a: 1u16, b: 1u16 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_scalar.out b/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_scalar.out index 678c0cade0..5f63e3003d 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_scalar.out +++ b/tests/expectations/compiler/core/algorithms/pedersen64_hash_to_scalar.out @@ -1,21 +1,29 @@ namespace = "Compile" -expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "06e11747d399574731bca182b2e1d20f739bb7ab8a39371982a4d13c1e55f7c7", type_checked_symbol_table = "b2c3d8c76e3e998845f610cd7baf8140a325e038f54736a6c3b04792d84880b8", unrolled_symbol_table = "b2c3d8c76e3e998845f610cd7baf8140a325e038f54736a6c3b04792d84880b8", initial_ast = "cb8e967fdf1777efe567de13891b0da23998aaf187904fa5f8d35cf7a49348a1", unrolled_ast = "cb8e967fdf1777efe567de13891b0da23998aaf187904fa5f8d35cf7a49348a1", ssa_ast = "b66a9a70ae78f3d3e3ca299f3d7880b33c228d18a5dcd28168f676acb87f331d", flattened_ast = "b6a2ead1af7c66a6989981646bd473264216d8f1427bb906ff12062048356b40", destructured_ast = "a669f9d1930eb958881871e006285cf23c4779903fb11ed88d871f1dd7b5d904", inlined_ast = "a669f9d1930eb958881871e006285cf23c4779903fb11ed88d871f1dd7b5d904", dce_ast = "f9eafbb3278de0ec7e2315592b5546e593341f5b086f5c2a558b086490525e83", bytecode = """ -program test.aleo; - -struct Foo: - a as u16; - b as u16; - -function main: - input r0 as i8.private; - input r1 as i16.private; - input r2 as i32.private; - input r3 as i64.private; - input r4 as u8.private; - input r5 as u16.private; - input r6 as u32.private; - input r7 as u64.private; - hash.ped64 aleo10qerras5799u6k7rjtc9y3hcwxuykr45qra7x7dp6jgnc0923czqm0lgta into r8 as scalar; - output r8 as scalar.private; -""", errors = "", warnings = "" }] }]] +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `address` was found. + --> compiler-test:27:52 + | + 27 | let a: scalar = Pedersen64::hash_to_scalar(addr_value); + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `field` was found. + --> compiler-test:29:52 + | + 29 | let c: scalar = Pedersen64::hash_to_scalar(field_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `group` was found. + --> compiler-test:30:52 + | + 30 | let d: scalar = Pedersen64::hash_to_scalar(group_value); + | ^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `scalar` was found. + --> compiler-test:37:52 + | + 37 | let m: scalar = Pedersen64::hash_to_scalar(scalar_value); + | ^^^^^^^^^^^^ +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `Foo` was found. + --> compiler-test:39:52 + | + 39 | let n: scalar = Pedersen64::hash_to_scalar(Foo { a: 1u16, b: 1u16 }); + | ^^^^^^^^^^^^^^^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/core/algorithms/pedersen_fail.out b/tests/expectations/compiler/core/algorithms/pedersen_fail.out index 1bdb8bb065..8dfa31cc37 100644 --- a/tests/expectations/compiler/core/algorithms/pedersen_fail.out +++ b/tests/expectations/compiler/core/algorithms/pedersen_fail.out @@ -1,12 +1,12 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372007]: Expected one type from `address, bool, field, group, struct, integer, scalar, struct`, but got `u128` +Error [ETYC0372117]: Expected an integer of less than 64 bits or a bool but type `u128` was found. --> compiler-test:5:50 | 5 | let a: group = Pedersen64::hash_to_field(1u128); // Pedersen64 hash_to_field returns a field type | ^^^^^ -Error [ETYC0372003]: Expected type `group` but type `field` was found +Error [ETYC0372117]: Expected type `group` but type `field` was found. --> compiler-test:5:24 | 5 | let a: group = Pedersen64::hash_to_field(1u128); // Pedersen64 hash_to_field returns a field type diff --git a/tests/expectations/compiler/core/cheatcodes/invalid_cheatcodes_fail.out b/tests/expectations/compiler/core/cheatcodes/invalid_cheatcodes_fail.out index 4205dced3d..47ead9d462 100644 --- a/tests/expectations/compiler/core/cheatcodes/invalid_cheatcodes_fail.out +++ b/tests/expectations/compiler/core/cheatcodes/invalid_cheatcodes_fail.out @@ -11,12 +11,12 @@ Error [ETYC0372005]: Unknown variable `account` | 14 | CheatCode::print_mapping(test_dep.aleo/account); | ^^^^^^^^^^^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `u32` but type `u64` was found +Error [ETYC0372117]: Expected type `u32` but type `u64` was found. --> compiler-test:15:37 | 15 | CheatCode::set_block_height(1u64); | ^^^^ -Error [ETYC0372003]: Expected type `u32` but type `u64` was found +Error [ETYC0372117]: Expected type `u32` but type `u64` was found. --> compiler-test:16:37 | 16 | CheatCode::set_block_height(a); diff --git a/tests/expectations/compiler/core/cheatcodes/valid_cheatcodes.out b/tests/expectations/compiler/core/cheatcodes/valid_cheatcodes.out index ff52b82d9e..1bfb8d0b58 100644 --- a/tests/expectations/compiler/core/cheatcodes/valid_cheatcodes.out +++ b/tests/expectations/compiler/core/cheatcodes/valid_cheatcodes.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "0fbe7b86610386bfb1c7f0f211b2043baae706b9195008f8553511968f9297e7", type_checked_symbol_table = "efc3324af11b2f3645010266f1a871d799b81b07bec594fa88402b3f6fe1330b", unrolled_symbol_table = "efc3324af11b2f3645010266f1a871d799b81b07bec594fa88402b3f6fe1330b", initial_ast = "472f984ad224e345de6a6a8cb7c4986b0bf8fa288713c38a506b41bad280faa5", unrolled_ast = "472f984ad224e345de6a6a8cb7c4986b0bf8fa288713c38a506b41bad280faa5", ssa_ast = "ff6501ea72e6a46b15d71a89b71181851fba9aa2e6ee2a36d70218ad1a089a68", flattened_ast = "ba4154876562575fc3f8b6106a3ed4ab331382a4538ebc9630c82ed9be48176b", destructured_ast = "a995365c129f150bc361a571e5a0810f014a62c170d39e904b7de473bcdac50f", inlined_ast = "3a2f11285208b9bd75048be921a23504d9389ae81e2bdc96f631943cfa4349c6", dce_ast = "ed19a1a5455d89e6a59914923e69d600b0fde7fa91cae652d70756eb59365e03", bytecode = """ + { initial_symbol_table = "3349dda351214687b35578120a51581edd42403e912458606d5740d7d29ae4dd", type_checked_symbol_table = "881447243aa23b39575f79716a9f9d9c087d03be1e7bd5f1d09c047725b41329", unrolled_symbol_table = "881447243aa23b39575f79716a9f9d9c087d03be1e7bd5f1d09c047725b41329", initial_ast = "328918d0b3dd6923b30d9ce7404976121e3dd96f32210e9fb514726faef7c2ef", unrolled_ast = "328918d0b3dd6923b30d9ce7404976121e3dd96f32210e9fb514726faef7c2ef", ssa_ast = "a29765973d8c7313f07a01152b5581c3a4a3c1267884e05a7fa16baf4d7eda9a", flattened_ast = "6c44e51bc580168e9f278da0e3a18813f062be0987e0b3011dab7bbdf0194b21", destructured_ast = "6a0ef2c464ec65e4d9f0f4a6d235e8212999712c19f967c6224a67899f42295b", inlined_ast = "2cfb650c684c9932c879bb78fcbc37d602d1ed8068af087b32b0a9e66084e4b1", dce_ast = "86830ad8e03a76f370944f3b12a6fe11ec4db8a520ee7e0e18ab7ec1c4986efb", bytecode = """ program test_dep.aleo; record yeets: diff --git a/tests/expectations/compiler/definition/define_multiple_variables_fail.out b/tests/expectations/compiler/definition/define_multiple_variables_fail.out index 8d1523dbb2..78712962ef 100644 --- a/tests/expectations/compiler/definition/define_multiple_variables_fail.out +++ b/tests/expectations/compiler/definition/define_multiple_variables_fail.out @@ -11,7 +11,7 @@ Error [ETYC0372072]: Expected a tuple with 3 elements, found one with 2 elements | 6 | let (d,e): (u8,u8,u8) = (1u8,2u8,3u8); | ^^^^^ -Error [ETYC0372003]: Expected type `(u8,u8,u8)` but type `u8` was found +Error [ETYC0372117]: Expected type `(u8, u8, u8)` but type `u8` was found. --> compiler-test:7:36 | 7 | let (g,h,i): (u8,u8,u8) = (1u8); diff --git a/tests/expectations/compiler/examples/auction.out b/tests/expectations/compiler/examples/auction.out index 274ecd1915..8e012eee9b 100644 --- a/tests/expectations/compiler/examples/auction.out +++ b/tests/expectations/compiler/examples/auction.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "e62c1b7c10399ecc5c160520319218d96b599b5cfd37add3032a8455552c7892", type_checked_symbol_table = "6b8247d514ab06d72b92f94ada2a29c109fdb033decdc417a95ba371a2323fcb", unrolled_symbol_table = "6b8247d514ab06d72b92f94ada2a29c109fdb033decdc417a95ba371a2323fcb", initial_ast = "2939c07bf811d0a110e3f4d41ce08332be4a6938213330fcda20502369155023", unrolled_ast = "2939c07bf811d0a110e3f4d41ce08332be4a6938213330fcda20502369155023", ssa_ast = "5b011875455c2efbb3c222c91b40f049ca074e3b21685e27bfff6ecf50359ecf", flattened_ast = "71235c2f490ba2f1d7cabccec771d68078a8313fa2ecbdb3a17e88410132bde4", destructured_ast = "236729b9a950bec2251d0ea55cc078f41437cdbd16beb05fa2910fbe6f671182", inlined_ast = "236729b9a950bec2251d0ea55cc078f41437cdbd16beb05fa2910fbe6f671182", dce_ast = "7477da18c60adbb27b8213fae81aea20b3a4efaf8e42369c468eb8cc1c8b5932", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "eb20ab396fe0e6965bcaaee417fddfd04b27436e73b4d7f6bf46354a4ce8d07e", type_checked_symbol_table = "f50379f16b722af3a55627b4db0f442e8cf8e91c958c998071be0d87d7d02941", unrolled_symbol_table = "f50379f16b722af3a55627b4db0f442e8cf8e91c958c998071be0d87d7d02941", initial_ast = "014e052391d2f27952e6de0f7afaf94ac06cd399f93bd197b93ad593d8644e49", unrolled_ast = "014e052391d2f27952e6de0f7afaf94ac06cd399f93bd197b93ad593d8644e49", ssa_ast = "c791ed1655e0d6b12abc298c5442225e479c64599e9bef0d6d1ef27880ab451b", flattened_ast = "e4c0fa59f046d31d8e80e507e30dc03ba9df178da4ba4bd13a84477ac357665f", destructured_ast = "74df548901d3abc4c04c5addfeed0548dc73ce57f2e12f322158e60120fab228", inlined_ast = "74df548901d3abc4c04c5addfeed0548dc73ce57f2e12f322158e60120fab228", dce_ast = "2546c436a9b29ede93c8e5cf62f222e5422cefb99f4487f367af3b07d26ada45", bytecode = """ program test.aleo; record Bid: diff --git a/tests/expectations/compiler/examples/basic_bank.out b/tests/expectations/compiler/examples/basic_bank.out index bb8bf2133e..95130489bf 100644 --- a/tests/expectations/compiler/examples/basic_bank.out +++ b/tests/expectations/compiler/examples/basic_bank.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "abe61054ca9df211b12060173d3acc1cd94d7dd48e1bd907b9e1aa15b92c93d9", type_checked_symbol_table = "945b5379ae48537f8fadbaf30876c78885d39f7cfa795e756bc6b4f016e4ecc1", unrolled_symbol_table = "0bbd5894a5358013b410a8f8e7af0cc454314f6ec92f369be24f257d59ded394", initial_ast = "75dcf9468ef37d52c5e5ec868637ba8d33c6476d76bce004c9c6ac4ec905e3ba", unrolled_ast = "112fcc76097784bf2a7d01e5588b7ee7a1ccfa74eea5f0f16c2a91efcbea13fd", ssa_ast = "566b51d62d9ccd2c7d180c63640e9b6aad68d9f3f380c350985417bd820305bc", flattened_ast = "826db74250d660f581a5b868dfd69c093472c194cd174c7a2b3df7d062b820be", destructured_ast = "0724b0d8e232c379b198d1d00453e70ba260eab0477d934f85d0543dd0d8caf6", inlined_ast = "35356c074003b4bf9673a83428041bf5fbc04d8ea0ca06250362834dfdc6693b", dce_ast = "3d405275856db1a0f883660bbbc9e0cff7210228856ad27d250ee560d166d545", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "78294a11549585557ba8c781342793e075dcc6840419b892ff37df2f23b33c6c", type_checked_symbol_table = "24c2796dc9660174c3013b709e4fe3bbca63d7836ea285a19d86eb3609f769fc", unrolled_symbol_table = "6610b9dde0643dfaa7e627d3f6f10c023b501345b6f4cad2ea34bae9c50cc01b", initial_ast = "afd0c43368595954066cc180e6d0a34219f99ffbf45ada7ddcb4321e0c2ef653", unrolled_ast = "f9882681dc07458860c74d0e7d05603c419a74822a5abc8ac41087b85761e57c", ssa_ast = "2729c8158b3b9a46c220650f10e8d9df94747acaed0bb9907165c57f3b4d3bc9", flattened_ast = "8efae0646b0ac5ce627f62647141fc232d395db37f5460bd5e1b96333334e217", destructured_ast = "838defeb12327fa063e9a80f5ff55427eca7e789f5615be913237348e412197a", inlined_ast = "6e6f7ce994f0ba16e3bd8368e7c4a19f721ee247e1afd3cb46118da24a65791c", dce_ast = "8178534c7c88a95e714f96e00b2a63fb9dbcbd3847586bc38c2e26abd071d02d", bytecode = """ program basic_bank.aleo; record Token: diff --git a/tests/expectations/compiler/examples/board.out b/tests/expectations/compiler/examples/board.out index 69296c079f..07cfe9494a 100644 --- a/tests/expectations/compiler/examples/board.out +++ b/tests/expectations/compiler/examples/board.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "480e3d1e1fdc4718c7f2a8a0b7a6b1a7f2243b74b49855f5468f1dc425fee8e7", type_checked_symbol_table = "d916e4ab2c45e95fb1da32e78d7bb089f2a38e09afc0a19d9249d659110bdff3", unrolled_symbol_table = "d916e4ab2c45e95fb1da32e78d7bb089f2a38e09afc0a19d9249d659110bdff3", initial_ast = "b0e1262b9d03522d0707dc941c7a4c8d7456a39c40b1b1b1e871211bbf523341", unrolled_ast = "acb9cb4c6e1c851516357aa55867049913fbd4b551fab4722e83ab4de82f5ba8", ssa_ast = "f137e104bbb7d7a0559a7266ffcddaa9a973d8111d9c37405ab4a27a8aa0ac9e", flattened_ast = "a45aaac9032646f13fdf858730d4d6b0f6c6d3af8e9febb654a847542a07b4a8", destructured_ast = "28b9eba3d18205fe1f17db1cb43bbf9fd9fbe58a09c85c7b5d777d6b8ea80769", inlined_ast = "28b9eba3d18205fe1f17db1cb43bbf9fd9fbe58a09c85c7b5d777d6b8ea80769", dce_ast = "28b9eba3d18205fe1f17db1cb43bbf9fd9fbe58a09c85c7b5d777d6b8ea80769", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "bff4ce63ddc2c22166b5e86112e7871e3fc30b5b460174b378892f9287061bf2", type_checked_symbol_table = "1fd8ebc4340033e4ca6fe5c738116f97e540d628d46f245e35d645449c36b88f", unrolled_symbol_table = "1fd8ebc4340033e4ca6fe5c738116f97e540d628d46f245e35d645449c36b88f", initial_ast = "45f31dfe621b5164f7ecde898c0cf98470c2acd163aa11fb042ff09ad1ef0ea9", unrolled_ast = "6c377330bbbcf12d95c44b97d40d289da7ab8e3c5ff0dd6aeff0e457774672db", ssa_ast = "eb6afaae75233e2bcf9ae3cc019180ac6bb9cd97d2e7563b5c45ae3c0d235da8", flattened_ast = "02ae084f99d1afd56deaef32a171ef53c2b83cb0e8423b0a1d9e8c0a828a13e4", destructured_ast = "bcfcd070c404d3b8b1d7dd40f79ad0a56e1e0af0fb4fd99004a31ede62df3bce", inlined_ast = "bcfcd070c404d3b8b1d7dd40f79ad0a56e1e0af0fb4fd99004a31ede62df3bce", dce_ast = "bcfcd070c404d3b8b1d7dd40f79ad0a56e1e0af0fb4fd99004a31ede62df3bce", bytecode = """ program test.aleo; record board_state: diff --git a/tests/expectations/compiler/examples/lottery.out b/tests/expectations/compiler/examples/lottery.out index 56707b8f18..6e16e7fd71 100644 --- a/tests/expectations/compiler/examples/lottery.out +++ b/tests/expectations/compiler/examples/lottery.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "de199bdd9ae2c78e94fa54ed8e8baf87c9537e41de5026ab0d14f53b83aacdb0", type_checked_symbol_table = "eb4dd79e5f9dc3a1743543cf2115709402096e611f33fa03ea993cdef8bc2ca7", unrolled_symbol_table = "eb4dd79e5f9dc3a1743543cf2115709402096e611f33fa03ea993cdef8bc2ca7", initial_ast = "73d93c0436d1f4d002aa332cd43a87a01b55b42159d6495575306c25046267c4", unrolled_ast = "73d93c0436d1f4d002aa332cd43a87a01b55b42159d6495575306c25046267c4", ssa_ast = "acd509aa91092052b0da10bf0cdf5f735abf19cd6eb36c8fa81bc76e81e9ae22", flattened_ast = "d3658d88011d718cf081dc6bba7ae8af03fee2fa087304c5d8380a45df7906e6", destructured_ast = "999d48666be8894ce006e9852315718a7f83cc950becbf190482fc18b9997dac", inlined_ast = "57d9676f2703db440cf5ed4100030689db993c8e84b445111844e8be24970960", dce_ast = "57d9676f2703db440cf5ed4100030689db993c8e84b445111844e8be24970960", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "603fec4a6591c71f6b28160b966105aacecc678c601c4957b2b9044462336666", type_checked_symbol_table = "1cb0e7b23c3867e86acf8902c436b868d248ce8c805960c4537c606f1d00e8a5", unrolled_symbol_table = "1cb0e7b23c3867e86acf8902c436b868d248ce8c805960c4537c606f1d00e8a5", initial_ast = "15b9546ab7a4c5d7beeb223816ddac37ea0572634bed5a2cc34bb311aa72e4cd", unrolled_ast = "15b9546ab7a4c5d7beeb223816ddac37ea0572634bed5a2cc34bb311aa72e4cd", ssa_ast = "232c939ca56f08e4b64bde91fe46378604c743c68d044734c4c0d87164feae0f", flattened_ast = "5d1ead6ab82deafdd0b1a0ef2bba29d5bcd013cef8696e992b1ee4b6d1c2b492", destructured_ast = "8aaca8c57b9195cf47bc6c7de8be3b4dbfd7a2577018fa2303d2c3824c5d0515", inlined_ast = "594722fe6c8f48eefc16c2bc6e4f7477a33d614dc460a9f140b414cc125181c6", dce_ast = "594722fe6c8f48eefc16c2bc6e4f7477a33d614dc460a9f140b414cc125181c6", bytecode = """ program lottery.aleo; record Ticket: diff --git a/tests/expectations/compiler/examples/message.out b/tests/expectations/compiler/examples/message.out index 9938da9101..256f8a97b5 100644 --- a/tests/expectations/compiler/examples/message.out +++ b/tests/expectations/compiler/examples/message.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "fb455f236aab153fd9f750766a9cf7e4c1d1918ff5b0f2a8d1ff649303753fcb", type_checked_symbol_table = "0bf394c4301d7959b38dbd32534372b12837f2323c5c231886b3446ad55e7e99", unrolled_symbol_table = "0bf394c4301d7959b38dbd32534372b12837f2323c5c231886b3446ad55e7e99", initial_ast = "a4d7ed400ef99c9aed387a69ad03347749a65128a90c578f0a7410edaf27bfee", unrolled_ast = "a4d7ed400ef99c9aed387a69ad03347749a65128a90c578f0a7410edaf27bfee", ssa_ast = "331ebd18ba6a6c3442c6e0ceae137ada6bc9e4596a9d72d742e2617e654c03a6", flattened_ast = "b6364e15a02c80b23bcb20a25b5994a8d34c03adb71994eace22c0343ec3ba76", destructured_ast = "96a2bb89a5fcb1474e6ea44a4beabbe2414c132504e3f9bb3c2baf9b2140101f", inlined_ast = "96a2bb89a5fcb1474e6ea44a4beabbe2414c132504e3f9bb3c2baf9b2140101f", dce_ast = "96a2bb89a5fcb1474e6ea44a4beabbe2414c132504e3f9bb3c2baf9b2140101f", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "6bc7ea8d5176066a3987e0aa6a67e1636cabec33acb9c69894709332f9a9019d", type_checked_symbol_table = "cb5b792cb4d85beac27cb2714d127d045731f04bf42dc3ee3f4b477b1df911d0", unrolled_symbol_table = "cb5b792cb4d85beac27cb2714d127d045731f04bf42dc3ee3f4b477b1df911d0", initial_ast = "313047d0d651ed17ee499024af389b2be5bf82cc6d17463ff545affdc990ae85", unrolled_ast = "313047d0d651ed17ee499024af389b2be5bf82cc6d17463ff545affdc990ae85", ssa_ast = "c965b5bcf32ac6b2964c84dcf3ffccdf169bc8abc844771127c06707cd0dc588", flattened_ast = "f44775c8340e34d6dd98594e671491a5c28bdce19dfc8eca30ac9c499c1c5d5c", destructured_ast = "9fa4e4a380e0da3e33b0a30dd98bb2e9c0181e8d59b314d47285de677d85d9ab", inlined_ast = "9fa4e4a380e0da3e33b0a30dd98bb2e9c0181e8d59b314d47285de677d85d9ab", dce_ast = "9fa4e4a380e0da3e33b0a30dd98bb2e9c0181e8d59b314d47285de677d85d9ab", bytecode = """ program test.aleo; struct Message: diff --git a/tests/expectations/compiler/examples/move.out b/tests/expectations/compiler/examples/move.out index 5c92d6c98a..168b9347ba 100644 --- a/tests/expectations/compiler/examples/move.out +++ b/tests/expectations/compiler/examples/move.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "3d9997e6053158f7417078040b0e807686d33f9b95d33cf1c074bd9562e8d9f2", type_checked_symbol_table = "ccfc94a41a9005689f8763b06abded5b70aff55cd5de737dcc4ba7b22f3d0eb1", unrolled_symbol_table = "ccfc94a41a9005689f8763b06abded5b70aff55cd5de737dcc4ba7b22f3d0eb1", initial_ast = "df1e83ca957224f18177bbb58afb309635ce7bafa88805bece080784aa59ad0b", unrolled_ast = "dacb4f3c7a6a20250a488a034d9580439bae339b72752813b4339ff686c1ac89", ssa_ast = "dc71372b5e7bec8375e0cc8e1f1cf02f2cc1412c7c1dfa18efeb7a4b212fb544", flattened_ast = "2e581db5670414963a26c9d11b581255053883e94ef6ad2ce4d7c961789c274d", destructured_ast = "0bb95d70f3d82f2d4bcbab48ae15539e4da50eedf57f931ef6fbf5eefdf13757", inlined_ast = "0bb95d70f3d82f2d4bcbab48ae15539e4da50eedf57f931ef6fbf5eefdf13757", dce_ast = "0bb95d70f3d82f2d4bcbab48ae15539e4da50eedf57f931ef6fbf5eefdf13757", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "0605650931510d53071891f6db6c85d5b58b9da5640f7e2abe85be6d1c68e6f4", type_checked_symbol_table = "b73b20ee4ffdd7ee8ee1cc3ef4106c2a8150eec336e31be31eef986700af2b0b", unrolled_symbol_table = "b73b20ee4ffdd7ee8ee1cc3ef4106c2a8150eec336e31be31eef986700af2b0b", initial_ast = "03104c19e9ed72e8a73198b3b31ad021d6112bab9ce08100acd3c416154e115d", unrolled_ast = "cc5a932618da597110500400d5a9259cafcbb3a9ee274e6a26188e93d9c74a03", ssa_ast = "0b8f7c70d869a2b153c5fe166cb0165d2dbc1cfa81ae02a824320624cd3c8157", flattened_ast = "4416715ce110328f289215c38dbe884c32d6e9b99439cc344c3e8a845baca51b", destructured_ast = "11e48c6e206d6f4e4834860dce4e16b1871223c075f721f2b8d2da840336699a", inlined_ast = "11e48c6e206d6f4e4834860dce4e16b1871223c075f721f2b8d2da840336699a", dce_ast = "11e48c6e206d6f4e4834860dce4e16b1871223c075f721f2b8d2da840336699a", bytecode = """ program test.aleo; record move: diff --git a/tests/expectations/compiler/examples/simple_token.out b/tests/expectations/compiler/examples/simple_token.out index a95b3aeb46..03bee18fdb 100644 --- a/tests/expectations/compiler/examples/simple_token.out +++ b/tests/expectations/compiler/examples/simple_token.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "513839497fb40242f53a43cda8848e446e9d690dad6e44ba3f0f60a96e3f97d5", type_checked_symbol_table = "4976db9708869fb0ea36157ad01efa5b491996d19f58dd3cc591c6cb7ca96a53", unrolled_symbol_table = "4976db9708869fb0ea36157ad01efa5b491996d19f58dd3cc591c6cb7ca96a53", initial_ast = "4ffbdb821e8aeed13f5c4948da6d4af54860df90f629e552130dfab7cb3c9a52", unrolled_ast = "4ffbdb821e8aeed13f5c4948da6d4af54860df90f629e552130dfab7cb3c9a52", ssa_ast = "ebc62bbd07b4b00e2956f7639cdba671d7f0245e715a7a48447c8631645072bd", flattened_ast = "1a57a40d2b2724705133ea6f0e685e73376591d72ad8192e18310c88575352e6", destructured_ast = "ec12bbeb130278dcdbcce2fa69c9e0f45dd44a6e4dea3b2b78c0634477d53f89", inlined_ast = "ec12bbeb130278dcdbcce2fa69c9e0f45dd44a6e4dea3b2b78c0634477d53f89", dce_ast = "ec12bbeb130278dcdbcce2fa69c9e0f45dd44a6e4dea3b2b78c0634477d53f89", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "1581b715e10c57c23228e4848c1996b3c03606e35178d105bfcbe2f60440a38d", type_checked_symbol_table = "3766d33e97f15f91317349a9f7b4e8464df87bcf199a8ba7757f9243b0a349a9", unrolled_symbol_table = "3766d33e97f15f91317349a9f7b4e8464df87bcf199a8ba7757f9243b0a349a9", initial_ast = "c793d5d450670bd09f83b857c7457bc2faf90bcc16748fb0c82e9147f2f9cedb", unrolled_ast = "c793d5d450670bd09f83b857c7457bc2faf90bcc16748fb0c82e9147f2f9cedb", ssa_ast = "288d3813c4ef1bda456b4ef0db6636bf6a605e2cc46d345d5d390d38aef6f154", flattened_ast = "5e683565cdee3b04e5c47f71fb1b8ab32b27ceb04ccfbd45a4c1903418cbc784", destructured_ast = "ad53d1bbdecd7d9cda9943327cac00d587398a85ee2d22d2abac1287ce8a2e8c", inlined_ast = "ad53d1bbdecd7d9cda9943327cac00d587398a85ee2d22d2abac1287ce8a2e8c", dce_ast = "ad53d1bbdecd7d9cda9943327cac00d587398a85ee2d22d2abac1287ce8a2e8c", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/compiler/examples/tictactoe.out b/tests/expectations/compiler/examples/tictactoe.out index 650b26f480..396d4f5fd0 100644 --- a/tests/expectations/compiler/examples/tictactoe.out +++ b/tests/expectations/compiler/examples/tictactoe.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "6aff4711eab46a594713d623b8a8952afa6539c74151c9ea47a37edc6f4a638c", type_checked_symbol_table = "b2fe6010b96888233278ce75a7d0fdf2e3e1a534e838be8b5989627735590b0c", unrolled_symbol_table = "b2fe6010b96888233278ce75a7d0fdf2e3e1a534e838be8b5989627735590b0c", initial_ast = "71f305a9a0f1cb9a7e7288f8d1e8e33dc60c563c8a79292bba93cbc47a22deab", unrolled_ast = "71f305a9a0f1cb9a7e7288f8d1e8e33dc60c563c8a79292bba93cbc47a22deab", ssa_ast = "386e22834051ea8712aaaf890074feecbb9f77bc00b1d527719ad6a65ec90bc8", flattened_ast = "2f3463ad9abfa67b2850103cee6e20b757afe556ea4230bcc424e7990a8aa517", destructured_ast = "fb144b2514b8a77b50cbb23d991275f3befef4f4d94ca5418610940065a7e6c5", inlined_ast = "91b896e11b7410d19a7aa69a7008d9da0cd5aa7d8e668d9219b35ee0a0b852d5", dce_ast = "b589f303efc5197399adef4ad347a7ac617b14c35e414a93c15e5ba38edf923e", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "d7739465bac93fa89ffe5416caebcfb64007365e864790e2436cf588f6bd2bd7", type_checked_symbol_table = "e9c9544942af6185e9bcebec9a1d29acb862ba6fcad29fee1ec1d6bde9a225cc", unrolled_symbol_table = "e9c9544942af6185e9bcebec9a1d29acb862ba6fcad29fee1ec1d6bde9a225cc", initial_ast = "3584a26d86130d6ad3bb692f3eff3b167222206b7d44ee43835ce07d0b7e5e76", unrolled_ast = "3584a26d86130d6ad3bb692f3eff3b167222206b7d44ee43835ce07d0b7e5e76", ssa_ast = "f2407bf497566c8bd95d00505ddb3c9e436eeefd64744ec5f939761a58cac7d3", flattened_ast = "484186242a9b95837908995fbef101b2b49a86b0b2684f1442f0f0ca2662a29e", destructured_ast = "b388bf974053b908787cbe4b2a4e1f2e53040f85c88a4e825d5a54c9d83915f7", inlined_ast = "257450ec934038addefdc0cb544bbecb1a2d4fe0ed0d1691e5ca171598e44568", dce_ast = "d37ef7f80c359fefeee9346da4b0d966d595f571bc29547908add3867108d527", bytecode = """ program test.aleo; struct Row: diff --git a/tests/expectations/compiler/examples/token.out b/tests/expectations/compiler/examples/token.out index d662254599..953f8b9eff 100644 --- a/tests/expectations/compiler/examples/token.out +++ b/tests/expectations/compiler/examples/token.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "e6630be283ece8f60bf19e68c600817b0ef278c19d7aef9fc3e5b31b00b060db", type_checked_symbol_table = "970ae60a9c72622950585cac77be9fa761471e17d2e5b4eb531790b342c6ff19", unrolled_symbol_table = "970ae60a9c72622950585cac77be9fa761471e17d2e5b4eb531790b342c6ff19", initial_ast = "b0916e5119f9754e055c2ca01281208939521e39bceebeb5a1e90f68d22aeffb", unrolled_ast = "b0916e5119f9754e055c2ca01281208939521e39bceebeb5a1e90f68d22aeffb", ssa_ast = "1546802d24cea35bc03a21e4796079a1e3e102e7b3afbc48fb6c0124b90083bf", flattened_ast = "1c4beac4af82905f22419f8ee99cc535cbdd88dfb63c418d645b0d487791e95f", destructured_ast = "e9bd9cb2760eebdc8187802df1d2e3f9ea4c8c8a709ac5eccc261412dbd3e168", inlined_ast = "c2e4f4eec7defbdeffc1a1e8be826907653f73e490a614fae5603fbe7c48e20d", dce_ast = "c2e4f4eec7defbdeffc1a1e8be826907653f73e490a614fae5603fbe7c48e20d", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "54bfe08745860787f2acc1769e0378303f9c40d19ebe503d2add5fc58d44c303", type_checked_symbol_table = "44c075442b2cc4d61b3f8aaeca4f17168948e29e6499fff3dd31c7c8ab75b9ed", unrolled_symbol_table = "44c075442b2cc4d61b3f8aaeca4f17168948e29e6499fff3dd31c7c8ab75b9ed", initial_ast = "cc51191d293d3bac46d02ea441ad7b82a8a0bfa7eb4f4b0012e6fd0c5775df0b", unrolled_ast = "cc51191d293d3bac46d02ea441ad7b82a8a0bfa7eb4f4b0012e6fd0c5775df0b", ssa_ast = "250dc3469d62a11a0b13e6fcbcf875c69f5c9640361dcbd9925ef69bc264f27e", flattened_ast = "cf927c8bd5ee0bb911b715826fd0947cc37c6cae1134f7418388bdd90c6413b6", destructured_ast = "996e183196f6f790bb36c5b3dd4006dc01f3f8f5caa91274bb644ace1af75931", inlined_ast = "2140163d75be4b6171cd4e2b7c6cd1c947adc7bf62f8e6c3ca784df858aa647d", dce_ast = "2140163d75be4b6171cd4e2b7c6cd1c947adc7bf62f8e6c3ca784df858aa647d", bytecode = """ program token.aleo; record token: diff --git a/tests/expectations/compiler/examples/vote.out b/tests/expectations/compiler/examples/vote.out index 3b1d16c373..59c4c61655 100644 --- a/tests/expectations/compiler/examples/vote.out +++ b/tests/expectations/compiler/examples/vote.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "11fbbf3ad2d03fafd4f7db39a5bfb0ea4b5302bdc422b26a4afa904887e8ea6b", type_checked_symbol_table = "fa1e31bf4b774f6039b03cbe5bc38eaf1bf9a85306ccbdef1f3a9b2976957018", unrolled_symbol_table = "fa1e31bf4b774f6039b03cbe5bc38eaf1bf9a85306ccbdef1f3a9b2976957018", initial_ast = "ed086619c9f0f5ad64417fcc17a6847fa22d1fa95b89f3ec58302928fd83b54c", unrolled_ast = "b1faf12359c2995083c2f483742076cd6b0c8c60bb90e95143b04d44a3c006bd", ssa_ast = "8a035bb369caeebb7b6b582f32aaa06b5bfddbf702c8e234fa927d7bb3557946", flattened_ast = "8cac8ffb570a503f38a5c980d08e985b5d8d299b5e6e38ceb5d21923ba21eae0", destructured_ast = "29a979bc9640fbefdb0f05a3974a8d6fb917acea2c4deed82b09aa524c12dd91", inlined_ast = "dcde5e49f60622fba629dd82b6ad39841230a4030793756066ea2d8093df6814", dce_ast = "dcde5e49f60622fba629dd82b6ad39841230a4030793756066ea2d8093df6814", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "a1cd41b747fc3dbf92544b23579192a0b02db40856894d7c674d632f42ce834f", type_checked_symbol_table = "e51b4e2a2d6caf932ee8b4b4faa53c77ac3e19eda436de87c7d9a885914f62f5", unrolled_symbol_table = "e51b4e2a2d6caf932ee8b4b4faa53c77ac3e19eda436de87c7d9a885914f62f5", initial_ast = "286e0bbcf36112e627140c68ff02f5fdcb6b0afae53c7b4645243aea1adf179d", unrolled_ast = "9f964fc8d192d8e56140e4d49d216b5d39eb46e451c77c1c5d391a595476bae9", ssa_ast = "45b3af11f2e2038890a24fd4b6edbe90d14d4ca4260170531bc21f7bfe2deae7", flattened_ast = "c0ff969e2ef34dedb489a7eb010289c2e7aee03f754f95edb6a1c1c399d77415", destructured_ast = "f774ceacf21981fd0e879038b7357ab13ff3e7a5b700c32bba0304751e3ca714", inlined_ast = "219362c945714a83b2eddbdc651955e922c65298f9510aac26625a2ecc3f88dc", dce_ast = "219362c945714a83b2eddbdc651955e922c65298f9510aac26625a2ecc3f88dc", bytecode = """ program vote.aleo; struct ProposalInfo: diff --git a/tests/expectations/compiler/expression/cast_coersion.out b/tests/expectations/compiler/expression/cast_coersion.out index 4e8debba93..c5448918d7 100644 --- a/tests/expectations/compiler/expression/cast_coersion.out +++ b/tests/expectations/compiler/expression/cast_coersion.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "736ef33d4ea34eb43862ee271decb4587901ab41e91e4f8e41b8f99d1f8b557c", type_checked_symbol_table = "1c73cb243b5146909a9fbd64fb8862bd15578904deaa7ce579d713e635bd0719", unrolled_symbol_table = "1c73cb243b5146909a9fbd64fb8862bd15578904deaa7ce579d713e635bd0719", initial_ast = "409d57cef21ca167d937cf70c1d7c116bc900e502831b395698e9d3f13ae0961", unrolled_ast = "409d57cef21ca167d937cf70c1d7c116bc900e502831b395698e9d3f13ae0961", ssa_ast = "7f12fbc88f56e33590cbb790827e4ec6a04fa9be41e6c1f2bf48515e430d9dc5", flattened_ast = "8e2378df83a8f59228993ec32ae9fbe19318052a3ced6b451b6f720ca6171257", destructured_ast = "8bc445642f52d44cedf36737681f945b99b647953026bb44a836eac1c3cd5d69", inlined_ast = "8bc445642f52d44cedf36737681f945b99b647953026bb44a836eac1c3cd5d69", dce_ast = "2a0e5585007503ef568572b188bae1212a4839548f624b022aafca1ce8e2cf24", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "0bf0ffecff11b7bba089bcff9c95483828b0a1f8a1cb3d3ad670ab4a2721b67a", type_checked_symbol_table = "2146f86583bba1627e873e6ee4415ee359db6c559e9fc3557ee6e0cfa321d4a5", unrolled_symbol_table = "2146f86583bba1627e873e6ee4415ee359db6c559e9fc3557ee6e0cfa321d4a5", initial_ast = "08984708d81bd8c596248ab8d77ce38653a8479679407f3134bcbeebd406f25e", unrolled_ast = "08984708d81bd8c596248ab8d77ce38653a8479679407f3134bcbeebd406f25e", ssa_ast = "54732170d48977af6114f483361ff5784efbca0f148ecc3fc23ff26a16919cbc", flattened_ast = "b3f751879e3e820a6dc1e11f4c1e09a7a4d91ada76d5ffa0822dda82d37b39d0", destructured_ast = "026996b7a2ec5ff49d1f6db2054c2f2178318f1e4bbee471bd4f21a61ed65e8b", inlined_ast = "026996b7a2ec5ff49d1f6db2054c2f2178318f1e4bbee471bd4f21a61ed65e8b", dce_ast = "12d9c436ad74690de1afb37d4e0b5712c1b803dcb83535498cf523e2a5ef9493", bytecode = """ program test.aleo; struct foo: diff --git a/tests/expectations/compiler/expression/cast_fail.out b/tests/expectations/compiler/expression/cast_fail.out index 55c1c89e4d..e8648257e4 100644 --- a/tests/expectations/compiler/expression/cast_fail.out +++ b/tests/expectations/compiler/expression/cast_fail.out @@ -6,22 +6,22 @@ Error [ETYC0372045]: Strings are not yet supported. | 13 | let b: string = a as string; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Error [ETYC0372007]: Expected one type from `field, group, scalar, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128, bool, address`, but got `string` +Error [ETYC0372117]: Expected an integer, bool, field, group, scalar, or address but type `string` was found. --> compiler-test:13:25 | 13 | let b: string = a as string; | ^^^^^^^^^^^ -Error [ETYC0372007]: Expected one type from `field, group, scalar, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128, bool, address`, but got `Foo` +Error [ETYC0372117]: Expected an integer, bool, field, group, scalar, or address but type `Foo` was found. --> compiler-test:16:24 | 16 | let d: field = c as field; | ^ -Error [ETYC0372007]: Expected one type from `field, group, scalar, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128, bool, address`, but got `(field,field)` +Error [ETYC0372117]: Expected an integer, bool, field, group, scalar, or address but type `(field, field)` was found. --> compiler-test:19:24 | 19 | let f: field = e as field; | ^ -Error [ETYC0372007]: Expected one type from `field, group, scalar, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128, bool, address`, but got `(field => field)` +Error [ETYC0372117]: Expected an integer, bool, field, group, scalar, or address but type `(field => field)` was found. --> compiler-test:25:24 | 25 | let b: field = balances as field; diff --git a/tests/expectations/compiler/finalize/finalize_incorrect_return_fail.out b/tests/expectations/compiler/finalize/finalize_incorrect_return_fail.out index c503396ab3..1a1e8e1641 100644 --- a/tests/expectations/compiler/finalize/finalize_incorrect_return_fail.out +++ b/tests/expectations/compiler/finalize/finalize_incorrect_return_fail.out @@ -11,14 +11,9 @@ Error [ETYC0372106]: An async function is not allowed to return a value. | ^ | = Remove an output type in the function signature, and remove the return statement from the function. Note that the future returned by async functions is automatically inferred, and must not be explicitly written. -Error [ETYC0372003]: Expected type `u64` but type `u8` was found +Error [ETYC0372117]: Expected type `u64` but type `u8` was found. --> compiler-test:12:16 | 12 | return 1u8 + 2u8; - | ^^^ -Error [ETYC0372003]: Expected type `u64` but type `u8` was found - --> compiler-test:12:22 - | - 12 | return 1u8 + 2u8; - | ^^^ + | ^^^^^^^^^ """] diff --git a/tests/expectations/compiler/finalize/get_incorrect_type_fail.out b/tests/expectations/compiler/finalize/get_incorrect_type_fail.out index c294aa350e..e43dbf2c94 100644 --- a/tests/expectations/compiler/finalize/get_incorrect_type_fail.out +++ b/tests/expectations/compiler/finalize/get_incorrect_type_fail.out @@ -6,22 +6,22 @@ Error [ETYC0372031]: A mapping's value cannot be a record | 10 | mapping tokens: address => Token; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `address` but type `bool` was found +Error [ETYC0372117]: Expected type `address` but type `bool` was found. --> compiler-test:17:30 | 17 | Mapping::get(tokens, true); | ^^^^ -Error [ETYC0372003]: Expected type `address` but type `bool` was found +Error [ETYC0372117]: Expected type `address` but type `bool` was found. --> compiler-test:18:20 | 18 | tokens.get(true); | ^^^^ -Error [ETYC0372003]: Expected type `address` but type `u8` was found +Error [ETYC0372117]: Expected type `address` but type `u8` was found. --> compiler-test:19:31 | 19 | Mapping::get(amounts, 1u8); | ^^^ -Error [ETYC0372003]: Expected type `address` but type `u8` was found +Error [ETYC0372117]: Expected type `address` but type `u8` was found. --> compiler-test:20:21 | 20 | amounts.get(1u8); diff --git a/tests/expectations/compiler/finalize/get_or_incorrect_type_fail.out b/tests/expectations/compiler/finalize/get_or_incorrect_type_fail.out index 8c3e666cc6..d8c7192f66 100644 --- a/tests/expectations/compiler/finalize/get_or_incorrect_type_fail.out +++ b/tests/expectations/compiler/finalize/get_or_incorrect_type_fail.out @@ -6,42 +6,42 @@ Error [ETYC0372031]: A mapping's value cannot be a record | 10 | mapping tokens: address => Token; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `Token` but type `u128` was found +Error [ETYC0372117]: Expected type `Token` but type `u128` was found. --> compiler-test:17:43 | 17 | Mapping::get_or_use(tokens, addr, amount); | ^^^^^^ -Error [ETYC0372003]: Expected type `Token` but type `u128` was found +Error [ETYC0372117]: Expected type `Token` but type `u128` was found. --> compiler-test:18:33 | 18 | tokens.get_or_use(addr, amount); | ^^^^^^ -Error [ETYC0372003]: Expected type `address` but type `u8` was found +Error [ETYC0372117]: Expected type `address` but type `u8` was found. --> compiler-test:19:38 | 19 | Mapping::get_or_use(amounts, 1u8, amount); | ^^^ -Error [ETYC0372003]: Expected type `address` but type `u8` was found +Error [ETYC0372117]: Expected type `address` but type `u8` was found. --> compiler-test:20:28 | 20 | amounts.get_or_use(1u8, amount); | ^^^ -Error [ETYC0372003]: Expected type `u128` but type `u8` was found +Error [ETYC0372117]: Expected type `u128` but type `u8` was found. --> compiler-test:21:44 | 21 | Mapping::get_or_use(amounts, addr, 1u8); | ^^^ -Error [ETYC0372003]: Expected type `u128` but type `u8` was found +Error [ETYC0372117]: Expected type `u128` but type `u8` was found. --> compiler-test:22:34 | 22 | amounts.get_or_use(addr, 1u8); | ^^^ -Error [ETYC0372003]: Expected type `u128` but type `u8` was found +Error [ETYC0372117]: Expected type `u128` but type `u8` was found. --> compiler-test:23:72 | 23 | Mapping::get_or_use(tokens, addr, Token { owner: addr, amount: 1u8 }); | ^^^ -Error [ETYC0372003]: Expected type `u128` but type `u8` was found +Error [ETYC0372117]: Expected type `u128` but type `u8` was found. --> compiler-test:24:62 | 24 | tokens.get_or_use(addr, Token { owner: addr, amount: 1u8 }); diff --git a/tests/expectations/compiler/finalize/mapping.out b/tests/expectations/compiler/finalize/mapping.out index 19d6e36537..ec82e8f663 100644 --- a/tests/expectations/compiler/finalize/mapping.out +++ b/tests/expectations/compiler/finalize/mapping.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "bc9d048929ff94bda88c39a484c09cb42ff7d864a0565ce0a2529f77c76f0bc1", type_checked_symbol_table = "52e5122f749ac108f5c53b481886ab92185918e770714b01c42f339e5f489712", unrolled_symbol_table = "52e5122f749ac108f5c53b481886ab92185918e770714b01c42f339e5f489712", initial_ast = "6b1148feeddff414c9f68c99246cd506dbe9195701805ad86a48fa3a14baba66", unrolled_ast = "6b1148feeddff414c9f68c99246cd506dbe9195701805ad86a48fa3a14baba66", ssa_ast = "3e375cbca9880dc515ec9f6d8d74597a3ae47412876a0e227ef175f0eafed9c1", flattened_ast = "46bc0a697fdd71c1f11d77f2316741634c5356009c89d4a9148f954c845e1618", destructured_ast = "a8e012d38d183720d972ff0be2b6ca37673db3d4b19e2c5dda0edb0626ec2496", inlined_ast = "a8e012d38d183720d972ff0be2b6ca37673db3d4b19e2c5dda0edb0626ec2496", dce_ast = "a8e012d38d183720d972ff0be2b6ca37673db3d4b19e2c5dda0edb0626ec2496", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "906a3559adfbc3be5194e974365f0f4c0b8284bd3df6595fc79a72934053c423", type_checked_symbol_table = "0ac498cf2315c09a47cbbb84e961d9053076374adce365e9527df807ffaa1869", unrolled_symbol_table = "0ac498cf2315c09a47cbbb84e961d9053076374adce365e9527df807ffaa1869", initial_ast = "f3b8edfaace5f948258ce134f0159d8dc9c8e7ac8bccef23f33d3c32b6116c11", unrolled_ast = "f3b8edfaace5f948258ce134f0159d8dc9c8e7ac8bccef23f33d3c32b6116c11", ssa_ast = "503fec3e5c8a24811647f4190ad4ebf78af890f11db45cb888ac5c89a13b0b61", flattened_ast = "433eb2f5da1bdc374aa1ebce07e10abcae10e878f1aa0a05c6fde0df5e72a264", destructured_ast = "b600f418c7ff02dbebcf46941a18c8a0ef96725c5664f6f58163ca0e3074b02e", inlined_ast = "b600f418c7ff02dbebcf46941a18c8a0ef96725c5664f6f58163ca0e3074b02e", dce_ast = "b600f418c7ff02dbebcf46941a18c8a0ef96725c5664f6f58163ca0e3074b02e", bytecode = """ program test.aleo; struct Token: diff --git a/tests/expectations/compiler/finalize/only_finalize_with_flattening.out b/tests/expectations/compiler/finalize/only_finalize_with_flattening.out index c0e4ea1fa4..697c06a88d 100644 --- a/tests/expectations/compiler/finalize/only_finalize_with_flattening.out +++ b/tests/expectations/compiler/finalize/only_finalize_with_flattening.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "83233a4d6b86c488fed94d68788771c6d66e8db5d8cc19e944b83ce37957dc38", type_checked_symbol_table = "15213e27a07d404c060fba06a8846df7bf56af827ac8fce15f373c9257615522", unrolled_symbol_table = "15213e27a07d404c060fba06a8846df7bf56af827ac8fce15f373c9257615522", initial_ast = "044081cc738c05a86903cfb285e4b2994e436bba8663f87f11ee6b6e16fd6bca", unrolled_ast = "044081cc738c05a86903cfb285e4b2994e436bba8663f87f11ee6b6e16fd6bca", ssa_ast = "134737377e2e27801bd823e7d90d56b99021e8d09cbac924ac73881ef1c5e47f", flattened_ast = "e3c07d14b70ed9bd4f02aeb3b1adac0b797298b5abf4ec4fbab6c476f0cbe11c", destructured_ast = "c6975e528196ae4b38d166b1ffe7a192cf0fa438d4b61f066b0f1c10928a857a", inlined_ast = "03f567618b1eb4e8ac17544dba2c6cfe122aa84a9fa592ea79c459f851acc461", dce_ast = "03f567618b1eb4e8ac17544dba2c6cfe122aa84a9fa592ea79c459f851acc461", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "419052e5912bee8c6b05315c9f99b90c36accefc8aa831373a6a833ffed994b1", type_checked_symbol_table = "a80cfd77d8f3f514ff5fcab29575f841e1691badb501c9b1f81ecf8c42dab800", unrolled_symbol_table = "a80cfd77d8f3f514ff5fcab29575f841e1691badb501c9b1f81ecf8c42dab800", initial_ast = "7c9e3e2bce2a78db910de8b7f09d594a9bfbce2d7d0a8cc5e837e55c0d81d9dd", unrolled_ast = "7c9e3e2bce2a78db910de8b7f09d594a9bfbce2d7d0a8cc5e837e55c0d81d9dd", ssa_ast = "6954318972ae7c5650dc285d6bdf92e1f031b22ab6c2d6ec766e3be96a76aa30", flattened_ast = "0600e1a04472460af1dc67e6062b68ccdeff612daf2a91b57089976d3394557e", destructured_ast = "8113445426edebba308048ff8bb437c4547925f01cca86b15faa523a65dcd5b1", inlined_ast = "0cc62bf540dbd73e23c7f8872bcf561972bae8c005d8d30ba81fc0890cbcbd93", dce_ast = "0cc62bf540dbd73e23c7f8872bcf561972bae8c005d8d30ba81fc0890cbcbd93", bytecode = """ program test.aleo; struct TokenInfo: diff --git a/tests/expectations/compiler/finalize/rand_incorrect_type_fail.out b/tests/expectations/compiler/finalize/rand_incorrect_type_fail.out index 4b38ec964c..a5b05b0478 100644 --- a/tests/expectations/compiler/finalize/rand_incorrect_type_fail.out +++ b/tests/expectations/compiler/finalize/rand_incorrect_type_fail.out @@ -1,12 +1,12 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `scalar` but type `field` was found +Error [ETYC0372117]: Expected type `scalar` but type `field` was found. --> compiler-test:12:25 | 12 | let a: scalar = ChaCha::rand_field(); | ^^^^^^^^^^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `group` but type `field` was found +Error [ETYC0372117]: Expected type `group` but type `field` was found. --> compiler-test:13:24 | 13 | let b: group = ChaCha::rand_field(); diff --git a/tests/expectations/compiler/finalize/set_in_an_assignment_fail.out b/tests/expectations/compiler/finalize/set_in_an_assignment_fail.out index e7274d7a24..f5dfba8c78 100644 --- a/tests/expectations/compiler/finalize/set_in_an_assignment_fail.out +++ b/tests/expectations/compiler/finalize/set_in_an_assignment_fail.out @@ -6,7 +6,7 @@ Error [ETYC0372055]: The left-hand side of a `DefinitionStatement` can only be a | 11 | let result: () = Mapping::set(amounts, addr, amount); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `u128` but type `()` was found +Error [ETYC0372117]: Expected type `u128` but type `()` was found. --> compiler-test:12:28 | 12 | let result: u128 = Mapping::set(amounts, addr, amount); diff --git a/tests/expectations/compiler/finalize/set_incorrect_type_fail.out b/tests/expectations/compiler/finalize/set_incorrect_type_fail.out index b9527bc9b2..0a41ca41ea 100644 --- a/tests/expectations/compiler/finalize/set_incorrect_type_fail.out +++ b/tests/expectations/compiler/finalize/set_incorrect_type_fail.out @@ -6,42 +6,42 @@ Error [ETYC0372031]: A mapping's value cannot be a record | 10 | mapping tokens: address => Token; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `Token` but type `u128` was found +Error [ETYC0372117]: Expected type `Token` but type `u128` was found. --> compiler-test:17:36 | 17 | Mapping::set(tokens, addr, amount); | ^^^^^^ -Error [ETYC0372003]: Expected type `Token` but type `u128` was found +Error [ETYC0372117]: Expected type `Token` but type `u128` was found. --> compiler-test:18:26 | 18 | tokens.set(addr, amount); | ^^^^^^ -Error [ETYC0372003]: Expected type `address` but type `u8` was found +Error [ETYC0372117]: Expected type `address` but type `u8` was found. --> compiler-test:19:31 | 19 | Mapping::set(amounts, 1u8, amount); | ^^^ -Error [ETYC0372003]: Expected type `address` but type `u8` was found +Error [ETYC0372117]: Expected type `address` but type `u8` was found. --> compiler-test:20:21 | 20 | amounts.set(1u8, amount); | ^^^ -Error [ETYC0372003]: Expected type `u128` but type `u8` was found +Error [ETYC0372117]: Expected type `u128` but type `u8` was found. --> compiler-test:21:37 | 21 | Mapping::set(amounts, addr, 1u8); | ^^^ -Error [ETYC0372003]: Expected type `u128` but type `u8` was found +Error [ETYC0372117]: Expected type `u128` but type `u8` was found. --> compiler-test:22:27 | 22 | amounts.set(addr, 1u8); | ^^^ -Error [ETYC0372003]: Expected type `u128` but type `u8` was found +Error [ETYC0372117]: Expected type `u128` but type `u8` was found. --> compiler-test:23:65 | 23 | Mapping::set(tokens, addr, Token { owner: addr, amount: 1u8 }); | ^^^ -Error [ETYC0372003]: Expected type `u128` but type `u8` was found +Error [ETYC0372117]: Expected type `u128` but type `u8` was found. --> compiler-test:24:55 | 24 | tokens.set(addr, Token { owner: addr, amount: 1u8 }); diff --git a/tests/expectations/compiler/function/dead_code_elimination.out b/tests/expectations/compiler/function/dead_code_elimination.out index f411131ede..4c72b78d1e 100644 --- a/tests/expectations/compiler/function/dead_code_elimination.out +++ b/tests/expectations/compiler/function/dead_code_elimination.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "0fb4b3c838108ed06c60f40a94768f70fb357b326302a58ff972f738739f1444", type_checked_symbol_table = "acb8ca7422d8053b2db7c29ef78353e450c7b85ae22f958020d4a33f3ba1c02f", unrolled_symbol_table = "acb8ca7422d8053b2db7c29ef78353e450c7b85ae22f958020d4a33f3ba1c02f", initial_ast = "d49dfe43c42214993dfb943c61df9c6827d0a2c776a096d557ac5ce39edbb596", unrolled_ast = "d49dfe43c42214993dfb943c61df9c6827d0a2c776a096d557ac5ce39edbb596", ssa_ast = "f20609affed799afc1e6c54febc34d12a9fc0fcd421fcacd9eb66f3a9513acca", flattened_ast = "9a863bf1d189402fdf36bb61f2e3db5226762c0ea91a023215e7d66566f3a38d", destructured_ast = "f6fafc3a3aef45ed4d3d2892e59a907c0e8617c6931b807f97c25879965a92c8", inlined_ast = "44f8af431773c3a33563240ed7e4ceb88e5ef11d2dbcadce87e4f1e34c07dd9b", dce_ast = "3aaebe40eb3e670c97b9418ef7685de0e4d6146d882830e98e0733212b4eee03", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "0fb4b3c838108ed06c60f40a94768f70fb357b326302a58ff972f738739f1444", type_checked_symbol_table = "3ee175692b854378be009003b00d35f72cfe08f6669cc069aea9ceb217a7b513", unrolled_symbol_table = "3ee175692b854378be009003b00d35f72cfe08f6669cc069aea9ceb217a7b513", initial_ast = "ffd02306f55309c354b25acbd124cc8758dcaddace98f578693675db24cdcb2c", unrolled_ast = "ffd02306f55309c354b25acbd124cc8758dcaddace98f578693675db24cdcb2c", ssa_ast = "f20609affed799afc1e6c54febc34d12a9fc0fcd421fcacd9eb66f3a9513acca", flattened_ast = "9a863bf1d189402fdf36bb61f2e3db5226762c0ea91a023215e7d66566f3a38d", destructured_ast = "f6fafc3a3aef45ed4d3d2892e59a907c0e8617c6931b807f97c25879965a92c8", inlined_ast = "44f8af431773c3a33563240ed7e4ceb88e5ef11d2dbcadce87e4f1e34c07dd9b", dce_ast = "3aaebe40eb3e670c97b9418ef7685de0e4d6146d882830e98e0733212b4eee03", bytecode = """ program test.aleo; record dummy: diff --git a/tests/expectations/compiler/function/flatten_arrays.out b/tests/expectations/compiler/function/flatten_arrays.out index 5d130ed957..f4a73938b8 100644 --- a/tests/expectations/compiler/function/flatten_arrays.out +++ b/tests/expectations/compiler/function/flatten_arrays.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "37bc119985fc346d7ac604986beb19629f6016e99ae5be8f8282f5755bdd6e43", type_checked_symbol_table = "d46a714294f78dce6339bd6480e1ee888ec57ab92a28a4b2e949647161e49a73", unrolled_symbol_table = "d46a714294f78dce6339bd6480e1ee888ec57ab92a28a4b2e949647161e49a73", initial_ast = "bceb61ae75b47e92e83ce5e6836b22b68854858bb24207c476e77f6580b20c4b", unrolled_ast = "bceb61ae75b47e92e83ce5e6836b22b68854858bb24207c476e77f6580b20c4b", ssa_ast = "695acd5239878bc6336d3628999bde308ea9e07b6cb45e61fd5586e72cd6faaa", flattened_ast = "a60a773110079c62010c5e2a82dd0c4d9ecc02e050c78e32effc3bf7307f7de0", destructured_ast = "a2d873b02a1ae206b71dd77ab3e2452fb3fe7e204778e42baec415d0ce9b85cd", inlined_ast = "e2939aaa893ac951eee3011e2ba14a75bc107a7d629ab17b665247844cf668cb", dce_ast = "5834dad1067cd1a345142ff7cb8f7d82c6eba50adf97971c3168b148d3e1c70b", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "aea1a31589142f0a6a07d217079ded686702f2756a2c522ab87732165a4d7b72", type_checked_symbol_table = "edf15b4aab9c8f0b48de29cb134f021122b6f02d1362833e2267917bf3565a90", unrolled_symbol_table = "edf15b4aab9c8f0b48de29cb134f021122b6f02d1362833e2267917bf3565a90", initial_ast = "fd7583fa5c45cf541e66faabbed572400aac55370989a605272f260fad6a3b9c", unrolled_ast = "fd7583fa5c45cf541e66faabbed572400aac55370989a605272f260fad6a3b9c", ssa_ast = "bd59694f39c85c6e7a0111c3c9982ac298841d5e864581b3e33a2d269c5b0879", flattened_ast = "87f985b3385321880074033cf83d3086454deec9530f3b8a6f4359c080b64dc9", destructured_ast = "faeca309b52b721a9de406cbb043e8070271c032b2b43629a6922e836542f125", inlined_ast = "7253ffe11d8fc9dd41bd90d130d8cf223b4da14f0a45f62acb35717beb7ddffe", dce_ast = "774e78b65c89e2cb8c66ab606c448760fb3d8bff7a2497bae2de3453cffdd048", bytecode = """ program test.aleo; struct Data: diff --git a/tests/expectations/compiler/function/flatten_inlined_tuples_of_structs.out b/tests/expectations/compiler/function/flatten_inlined_tuples_of_structs.out index 14a7d8902f..0991cc4126 100644 --- a/tests/expectations/compiler/function/flatten_inlined_tuples_of_structs.out +++ b/tests/expectations/compiler/function/flatten_inlined_tuples_of_structs.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "c138455fffa3721dbe11d7de65dd88130421ec4f07524779ff45ee87d01715d6", type_checked_symbol_table = "ead044ce635fb4af279cc26d4a8947b27e584ea3c606191e391392fbcc67e39a", unrolled_symbol_table = "ead044ce635fb4af279cc26d4a8947b27e584ea3c606191e391392fbcc67e39a", initial_ast = "4eaffbe5275c9202a13ecd96325d64711dd28510408da03cb69305b957cc0e88", unrolled_ast = "4eaffbe5275c9202a13ecd96325d64711dd28510408da03cb69305b957cc0e88", ssa_ast = "d9500a5e75ac40d45f1cb1ca6e625f9a1dee7e46f3071016f52d5290af49ab70", flattened_ast = "72ecc5ed171c827877906534005f04450bb636efea54c08507026e6b15857862", destructured_ast = "aed326f6c20b340137dd91f2303705c2c71d7b34140967a74ba3508e612c3399", inlined_ast = "db6efe2d8c097043958fb85b644a36a6f888adc58772596ef6656087075fa8bd", dce_ast = "850d749160d2a12943ad2e94d47a83b1475bbc224830ab74f4ec598cc6f826d4", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "d2ca6ba3d22d37e62b385800f03dfeacc6578bbb8535e4c453cad8e488d38559", type_checked_symbol_table = "49917cfb783cb3eecdcbce13ba9cb3f4d9973272c8570639ada222c35ef92587", unrolled_symbol_table = "49917cfb783cb3eecdcbce13ba9cb3f4d9973272c8570639ada222c35ef92587", initial_ast = "80930ad4cb7f61770ea7357480c75ac2827b4efb16f96e4f0ed8e46516cac7d3", unrolled_ast = "80930ad4cb7f61770ea7357480c75ac2827b4efb16f96e4f0ed8e46516cac7d3", ssa_ast = "fa0d332341ce2232bc73845c04388ed4c4de5273a33bfaf61b392cc0a05bde7b", flattened_ast = "d19a87ce540e4fae4b3fe88b0c26962c40819063f605a9964897d9dbfb222313", destructured_ast = "8a9a86db2c2d736b230ed8e9fb6d5bedc2f1e106c587803d024a34a4ee1a049f", inlined_ast = "31777e8e3f516684cdd5d3c491ef510e43f1abf8f5c52a5b5f43e4f469492616", dce_ast = "a4c1a16d010274fb72cfc5f40297db7856c2515d639fc60efa4dff69605f0c4d", bytecode = """ program test.aleo; struct Extra: diff --git a/tests/expectations/compiler/function/flatten_test.out b/tests/expectations/compiler/function/flatten_test.out index 79e04432e3..a50b6f0936 100644 --- a/tests/expectations/compiler/function/flatten_test.out +++ b/tests/expectations/compiler/function/flatten_test.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "38ad3bcd37a0f5ed42c4a5872d672838cf9c898915be3b5bd7cbe2e2c951116d", type_checked_symbol_table = "b06fff41daf8404608d3d84047a555f8b8abffceb060e9bd6c30d66d53044de3", unrolled_symbol_table = "b06fff41daf8404608d3d84047a555f8b8abffceb060e9bd6c30d66d53044de3", initial_ast = "aebc1a11c608a03ea9a3c30d82b635663b49753effe19404d97f273f58186b14", unrolled_ast = "aebc1a11c608a03ea9a3c30d82b635663b49753effe19404d97f273f58186b14", ssa_ast = "d227ff7eddc4e74d61b8e302f60fe9bf7b436f057606a4b5559d79af57ab3d1a", flattened_ast = "05a894445077f3505e800a089c6ddc475826a9de0f0a1b134c98512ea738e049", destructured_ast = "924a5eb5bd60f7537b4669db6e393e6945bab38ae99ee68c6750ffe4666ec7a4", inlined_ast = "3b7bbfbbe85929f77a46135310d8d8fc2cd41396185ad3a1e2abe8ca91dcc8fb", dce_ast = "011d693fae83c7f85f8cb3735aa82b0a0352301b0b0576ddb975bf93a578c32a", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "9535a2897a4656370dd6d18248102387fafd6988fde9cb84a940ef5385d5e3bc", type_checked_symbol_table = "b29e9dc7282b819db516ffb37182b6d8ffabdfc57e7b3654796bf97172a5849c", unrolled_symbol_table = "b29e9dc7282b819db516ffb37182b6d8ffabdfc57e7b3654796bf97172a5849c", initial_ast = "3ec85a0ec7aa394039254a13a0c280e9caaa1ee3f25d9e14d36e9a2de0a7f335", unrolled_ast = "3ec85a0ec7aa394039254a13a0c280e9caaa1ee3f25d9e14d36e9a2de0a7f335", ssa_ast = "81357ca332a2a7f57461273f71e43a2e804c817ceaadb569390a217a03c677d3", flattened_ast = "9fe02c591e9071c74ec613413553ed7bff00b422dcc70621b1de145b6c27bcae", destructured_ast = "f6943a454ec373b441e9a261ff2539fb5018e43e8f46c50e35145fbe63893881", inlined_ast = "4e431878f087e5af408b05db24ede6d7123efeb939364b4bb4543da715a1de28", dce_ast = "4e1ea5e2b86e76c30ae0cb75cf8b03ca3c844ebef38ea307bec48e91d843af84", bytecode = """ program test.aleo; struct Row: diff --git a/tests/expectations/compiler/function/flatten_test_2.out b/tests/expectations/compiler/function/flatten_test_2.out index c54f6f9526..05e4d2fbf4 100644 --- a/tests/expectations/compiler/function/flatten_test_2.out +++ b/tests/expectations/compiler/function/flatten_test_2.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[ - { compile = [{ initial_symbol_table = "9e57e65210ef32910c6d8f0fe0400f29ad320300aab89f780458722694f6f862", type_checked_symbol_table = "fdd69bb74cee526091393b6a1983534172224b2b571a881d4376f251b7cf7b4e", unrolled_symbol_table = "fdd69bb74cee526091393b6a1983534172224b2b571a881d4376f251b7cf7b4e", initial_ast = "47182c12d4f7003819d71a9e7e352077b302b73e11037a316f0a141fbe4b9b12", unrolled_ast = "47182c12d4f7003819d71a9e7e352077b302b73e11037a316f0a141fbe4b9b12", ssa_ast = "245399f8485816f9687ebe4a758067ee86c38c65772e11c7e952e3efba46c45c", flattened_ast = "1cbaf23a82ac78edd880cce14f97ca791ad05586c2b298305b5d116c66f741cd", destructured_ast = "7399f593b39548470b1c26f25ca1336b4c565f30383515c19bf2b7d2b7595194", inlined_ast = "7399f593b39548470b1c26f25ca1336b4c565f30383515c19bf2b7d2b7595194", dce_ast = "867c80b990ef129c07631f494d2f26a249d769cae7f407ea569112d696db659c", bytecode = """ + { compile = [{ initial_symbol_table = "9e57e65210ef32910c6d8f0fe0400f29ad320300aab89f780458722694f6f862", type_checked_symbol_table = "9af066fb5907d006ade91263c83f71e747f0deac4dc481acee2e3e70c0c9c418", unrolled_symbol_table = "9af066fb5907d006ade91263c83f71e747f0deac4dc481acee2e3e70c0c9c418", initial_ast = "a03b62665e30eedea3d493842083160f588787e920e25c1b53caeeaf780fa985", unrolled_ast = "a03b62665e30eedea3d493842083160f588787e920e25c1b53caeeaf780fa985", ssa_ast = "245399f8485816f9687ebe4a758067ee86c38c65772e11c7e952e3efba46c45c", flattened_ast = "1cbaf23a82ac78edd880cce14f97ca791ad05586c2b298305b5d116c66f741cd", destructured_ast = "7399f593b39548470b1c26f25ca1336b4c565f30383515c19bf2b7d2b7595194", inlined_ast = "7399f593b39548470b1c26f25ca1336b4c565f30383515c19bf2b7d2b7595194", dce_ast = "867c80b990ef129c07631f494d2f26a249d769cae7f407ea569112d696db659c", bytecode = """ program test.aleo; struct TokenInfo: @@ -9,7 +9,7 @@ struct TokenInfo: function add_new_liquidity_token_2: """, errors = "", warnings = "" }] }, - { compile = [{ initial_symbol_table = "2645407f9ede04b353e82835d65996cf912fd1e8634a61f461d457a92305b9ce", type_checked_symbol_table = "4e9ce7072216712da8f565266c66371443d6761ea10f891042d97b457145b669", unrolled_symbol_table = "4e9ce7072216712da8f565266c66371443d6761ea10f891042d97b457145b669", initial_ast = "ae96cef2402ff3fac80cc3363313fbdff221e2bfbf5ce30655bc1985be92210b", unrolled_ast = "ae96cef2402ff3fac80cc3363313fbdff221e2bfbf5ce30655bc1985be92210b", ssa_ast = "70025d49470fabc8804bb98b54ae1d0d0d5d5943fc9d3e6e76b708f346aef7c1", flattened_ast = "806c948265ae74e02fa0130bf2f66a572c0327341a6d990031fa5afee46a4182", destructured_ast = "2863f3ca7be0e5bbfd5754c2e091dc6481bce1473d91b5bff1256ebb63e48f55", inlined_ast = "2863f3ca7be0e5bbfd5754c2e091dc6481bce1473d91b5bff1256ebb63e48f55", dce_ast = "2863f3ca7be0e5bbfd5754c2e091dc6481bce1473d91b5bff1256ebb63e48f55", bytecode = """ + { compile = [{ initial_symbol_table = "2645407f9ede04b353e82835d65996cf912fd1e8634a61f461d457a92305b9ce", type_checked_symbol_table = "a3df8985389b7986e2d04b876118f5fc7b57e8aca55ac727863af86f23de8d83", unrolled_symbol_table = "a3df8985389b7986e2d04b876118f5fc7b57e8aca55ac727863af86f23de8d83", initial_ast = "d4a2d9b3ae480ba78e5d645c99fe3e52421213cb3899d32e6cb57962271f3500", unrolled_ast = "d4a2d9b3ae480ba78e5d645c99fe3e52421213cb3899d32e6cb57962271f3500", ssa_ast = "70025d49470fabc8804bb98b54ae1d0d0d5d5943fc9d3e6e76b708f346aef7c1", flattened_ast = "806c948265ae74e02fa0130bf2f66a572c0327341a6d990031fa5afee46a4182", destructured_ast = "2863f3ca7be0e5bbfd5754c2e091dc6481bce1473d91b5bff1256ebb63e48f55", inlined_ast = "2863f3ca7be0e5bbfd5754c2e091dc6481bce1473d91b5bff1256ebb63e48f55", dce_ast = "2863f3ca7be0e5bbfd5754c2e091dc6481bce1473d91b5bff1256ebb63e48f55", bytecode = """ program test.aleo; struct TokenInfo: diff --git a/tests/expectations/compiler/function/flatten_tuples_of_structs.out b/tests/expectations/compiler/function/flatten_tuples_of_structs.out index 5e483c5aff..d05af99200 100644 --- a/tests/expectations/compiler/function/flatten_tuples_of_structs.out +++ b/tests/expectations/compiler/function/flatten_tuples_of_structs.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "d964d8a38b2e4c8e33fd7a00bb030825ad72e30dc6530ebbe8196fca68a93e90", type_checked_symbol_table = "0cb246294e6a9c962e0596a8ff53a451bce88a9edfe538fbe86dfd919f789921", unrolled_symbol_table = "0cb246294e6a9c962e0596a8ff53a451bce88a9edfe538fbe86dfd919f789921", initial_ast = "35bd2bdf56095dd40ac177376dc338e04f1c08c7319d2412b51a23478ad098e8", unrolled_ast = "35bd2bdf56095dd40ac177376dc338e04f1c08c7319d2412b51a23478ad098e8", ssa_ast = "d2990bbfa8df60235f5df4065f98680019c6a4fcf9793a6f980f0365b84b6681", flattened_ast = "4f38814ab57e9f6b3d19fe9f77f2b55a78a295fab5a0141624303c654c0fa57a", destructured_ast = "79cd2e10db60a3edb72d6fc60948e546aa5d802f1ec59ddbb0879659908a296a", inlined_ast = "3b4a09203106b129a51aac843cf1cbf302f58e136c55f3a0e18f5bebc6a616be", dce_ast = "9adc8fd775f02506e08404f56c7c9ea6cd09971594f25078072fbc658dfa8057", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "d145e5a3b726f26a110363ca3da436af7f5dc133c64d1d9e27067c5154f8e423", type_checked_symbol_table = "840e13197052e09d99c24518ee22acfdb549b9006b2e2e7793d15fb757992698", unrolled_symbol_table = "840e13197052e09d99c24518ee22acfdb549b9006b2e2e7793d15fb757992698", initial_ast = "cb7562eb6790c9575bdebee3bf93ea4ea82b5ae67adf4743fab755ef02816b79", unrolled_ast = "cb7562eb6790c9575bdebee3bf93ea4ea82b5ae67adf4743fab755ef02816b79", ssa_ast = "6f8bedeb17fbc7ab0bedae336d52e6c50b6e1d388c47807e128eebc386ef36bd", flattened_ast = "3775d01f9ef9eb186462484c82c7e2299abea4f21b2247cf7c51c6cd185846ea", destructured_ast = "3f160a89ae2d135006d3134e8a38da5428bd6ff299cfdcc5978e16d0a9968418", inlined_ast = "69487fa9fa59a1a90e00e4c1bd175f457f99747ffa182cb4bdc71dac8db57c92", dce_ast = "791008944c516410ef19ca7384c9ee11c40921cc0e2c4c20ae30d2cac47ad392", bytecode = """ program test.aleo; struct Extra: diff --git a/tests/expectations/compiler/function/function_call_tyc_fail.out b/tests/expectations/compiler/function/function_call_tyc_fail.out index a664f96754..c97e517cd3 100644 --- a/tests/expectations/compiler/function/function_call_tyc_fail.out +++ b/tests/expectations/compiler/function/function_call_tyc_fail.out @@ -11,7 +11,7 @@ Error [ETYC0372003]: Expected type `i8` but type `u8` was found | 20 | y = f3(y, z); | ^^^^^^^^ -Error [ETYC0372003]: Expected type `u8` but type `i8` was found +Error [ETYC0372117]: Expected type `u8` but type `i8` was found. --> compiler-test:20:16 | 20 | y = f3(y, z); diff --git a/tests/expectations/compiler/function/helper_function_with_interface.out b/tests/expectations/compiler/function/helper_function_with_interface.out index 17eb198771..d085460de7 100644 --- a/tests/expectations/compiler/function/helper_function_with_interface.out +++ b/tests/expectations/compiler/function/helper_function_with_interface.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "ec20dd09711f4d662bb010c4edf90412d5667f25229b19d0040d80ecdd59af05", type_checked_symbol_table = "7ce9a710af70a1ca92f26cdce6cbfca6d2c908a7f54456f2f7a25a097766efba", unrolled_symbol_table = "7ce9a710af70a1ca92f26cdce6cbfca6d2c908a7f54456f2f7a25a097766efba", initial_ast = "4e274607321e481e80735f922a86f31ee94b1beced6860764cef81da822a70b8", unrolled_ast = "4e274607321e481e80735f922a86f31ee94b1beced6860764cef81da822a70b8", ssa_ast = "06352349c992e6fca231dab0ed6a47a0b8e44366a71dbc8ef07bdcd4621a44d7", flattened_ast = "0030eca0e443f9ad10f18573d1abd47680923afc0c161268e522456a60c9d5b2", destructured_ast = "32581512b36a175bab2a9e9fb8ee3b2cc37de33686bc49d686f5ac5fc794f348", inlined_ast = "32581512b36a175bab2a9e9fb8ee3b2cc37de33686bc49d686f5ac5fc794f348", dce_ast = "32581512b36a175bab2a9e9fb8ee3b2cc37de33686bc49d686f5ac5fc794f348", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "bf6a83840fe08999ac5964491a78c68843327fe6721b8994288a75faf0f65ce6", type_checked_symbol_table = "a7330fc1d8a6dd816456506eba1eaf5fc02997dfe985a10727a10b5dcc3a2fd6", unrolled_symbol_table = "a7330fc1d8a6dd816456506eba1eaf5fc02997dfe985a10727a10b5dcc3a2fd6", initial_ast = "aa4a1a0f9e75a5b4b8af1232b601a8901b54421c041d5745df979cb9e668e18c", unrolled_ast = "aa4a1a0f9e75a5b4b8af1232b601a8901b54421c041d5745df979cb9e668e18c", ssa_ast = "1010eb033d528e2c47d8f0f815ab72366470696d8be0597b8134fee5d3f20967", flattened_ast = "a3d6e47fd24d2de910f133f9f10b6059d231a61244d5ac24508c7b21df083283", destructured_ast = "50e3a564e7551ffa6f7c6eb6866dfc556a0dfaeb1b60ba7588d476b652ca4ffd", inlined_ast = "50e3a564e7551ffa6f7c6eb6866dfc556a0dfaeb1b60ba7588d476b652ca4ffd", dce_ast = "50e3a564e7551ffa6f7c6eb6866dfc556a0dfaeb1b60ba7588d476b652ca4ffd", bytecode = """ program test.aleo; struct Board: diff --git a/tests/expectations/compiler/function/record_in_conditional_return.out b/tests/expectations/compiler/function/record_in_conditional_return.out index 97f02b150d..6a34cc9dae 100644 --- a/tests/expectations/compiler/function/record_in_conditional_return.out +++ b/tests/expectations/compiler/function/record_in_conditional_return.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "d5ea2324dee9fefc1c1266aa3984173753649bfe5c3b90ecc38c1e9923a278a0", type_checked_symbol_table = "cd4b664d03514db45cebcbd9ba62b3403d49fb498838e73352e87cd7558d8cb7", unrolled_symbol_table = "cd4b664d03514db45cebcbd9ba62b3403d49fb498838e73352e87cd7558d8cb7", initial_ast = "0f32aead0f48227cb0c4c01f6e034c16e83b58c285fb02fda1b651389e6003b5", unrolled_ast = "0f32aead0f48227cb0c4c01f6e034c16e83b58c285fb02fda1b651389e6003b5", ssa_ast = "1eff92c09f76a87a712c3540266c67df2968a2a12c079d341fc42f1faf2024a9", flattened_ast = "76a3571ec39036a4e246c5a6e9f9cecff922d18d859cfa58e6165772872b3cbc", destructured_ast = "f5d61fc324d462caa8fd59843c5125da2306f1d2d5a87cc79c2b699c39228a6f", inlined_ast = "f5d61fc324d462caa8fd59843c5125da2306f1d2d5a87cc79c2b699c39228a6f", dce_ast = "abb41334bcee8b02f350d058659e62dc767c34393bb41ac2e4b6dc4127144bd8", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "870ee685a8df7826d96d98a13622f88f14395dd0ee88b4ad5fcda962d1a84dcf", type_checked_symbol_table = "a7ef2a89a81a56ffabaf99de47dfbe0fd4ea4fb0ff9881134cf300ffb89e7547", unrolled_symbol_table = "a7ef2a89a81a56ffabaf99de47dfbe0fd4ea4fb0ff9881134cf300ffb89e7547", initial_ast = "5cad29e66986839987f1d3269b7693923e90a9a25b757dd7d0e9dde489a1b1cf", unrolled_ast = "5cad29e66986839987f1d3269b7693923e90a9a25b757dd7d0e9dde489a1b1cf", ssa_ast = "f1bf8ff6c73eb9fedf14a73f4f7bacf0e630b4699dcf1d110c0bcaada5ab094e", flattened_ast = "4149c04fa5dafb54cc517ae5cae7f5bb46e0d48c7f19ddef762a62bb5dfdaf70", destructured_ast = "a240e68fd900d3b7e0ee696798fc2dacf13d90dea50b6e416d672e84ef7adf03", inlined_ast = "a240e68fd900d3b7e0ee696798fc2dacf13d90dea50b6e416d672e84ef7adf03", dce_ast = "8155ad8671b28c1a5394646bbd0773310cc2f710077c9fe1cd7ec9002dcec150", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/compiler/function/self_fail.out b/tests/expectations/compiler/function/self_fail.out index 971acb4ea9..eeebe6ec96 100644 --- a/tests/expectations/compiler/function/self_fail.out +++ b/tests/expectations/compiler/function/self_fail.out @@ -6,9 +6,4 @@ Error [ETYC0372040]: The allowed accesses to `self` are `self.caller` and `self. | 5 | return self.foo == addr; | ^^^ -Error [ETYC0372003]: Expected type `address` but type `no type` was found - --> compiler-test:5:16 - | - 5 | return self.foo == addr; - | ^^^^^^^^^^^^^^^^ """] diff --git a/tests/expectations/compiler/function/unknown_parameter_type_fail.out b/tests/expectations/compiler/function/unknown_parameter_type_fail.out index e7e1376626..fc6d83209b 100644 --- a/tests/expectations/compiler/function/unknown_parameter_type_fail.out +++ b/tests/expectations/compiler/function/unknown_parameter_type_fail.out @@ -15,7 +15,7 @@ Error [ETYC0372017]: The type `Foo` is not found in the current scope. | ^^^ | = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits` -Error [ETYC0372003]: Expected type `Foo` but type `u8` was found +Error [ETYC0372117]: Expected type `Foo` but type `u8` was found. --> compiler-test:9:16 | 9 | return a; diff --git a/tests/expectations/compiler/futures/async_before_call_fail.out b/tests/expectations/compiler/futures/async_before_call_fail.out new file mode 100644 index 0000000000..5dc665f10a --- /dev/null +++ b/tests/expectations/compiler/futures/async_before_call_fail.out @@ -0,0 +1,11 @@ +namespace = "Compile" +expectation = "Fail" +outputs = [""" +Error [ETYC0372102]: External transition calls cannot be made after local async function call + --> compiler-test:8:9 + | + 8 | child.aleo/t(); + | ^^^^^^^^^^^^^^ + | + = Move the async function call before the transition call. +"""] diff --git a/tests/expectations/compiler/futures/future_in_tuple.out b/tests/expectations/compiler/futures/future_in_tuple.out index 143c38c3c0..93569f8f5a 100644 --- a/tests/expectations/compiler/futures/future_in_tuple.out +++ b/tests/expectations/compiler/futures/future_in_tuple.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "e19a77f482bf38e20c7ecd69838dadb5e778a6a95c1de2eb56bddc42121b8940", type_checked_symbol_table = "33b1b5c2459bfa8d5c5b4b740965f4d59e09990037934364b94f1cb2e6316c2f", unrolled_symbol_table = "33b1b5c2459bfa8d5c5b4b740965f4d59e09990037934364b94f1cb2e6316c2f", initial_ast = "65074d34d89168f67b8db62c7b091b8c02e93aeda11f79c218c3761e270f8c09", unrolled_ast = "65074d34d89168f67b8db62c7b091b8c02e93aeda11f79c218c3761e270f8c09", ssa_ast = "3b05d816fbca67dce63e2f851a77f8ffa65930e3eb094c01647f05d251305632", flattened_ast = "6fa4c0335842d7ba9412438bbf35dcd75843107f14a25ebeb16b8a150bee11b7", destructured_ast = "f21d1fc10d1ebd9a86273f17a20bd1cd1247c1ce1456f9ad252cb7c4f5bb10bb", inlined_ast = "3cb6765aec323b35119157dd2e3264aead6820169d79b182c256f499af1ff5a8", dce_ast = "3cb6765aec323b35119157dd2e3264aead6820169d79b182c256f499af1ff5a8", bytecode = """ + { initial_symbol_table = "cfa2a90e022ef95d4ed67618319b6524f6ef27bfceb5dd7fcf5a460f3561186c", type_checked_symbol_table = "7904a6d030dd5ec653e394ca76cb3be13f60ef193a09b7dfdd0a3dff2bf76c94", unrolled_symbol_table = "7904a6d030dd5ec653e394ca76cb3be13f60ef193a09b7dfdd0a3dff2bf76c94", initial_ast = "6af04f6b10b40e3a7a009f117b421ef20ad0880ce93b39f1b937ac56f73ff716", unrolled_ast = "6af04f6b10b40e3a7a009f117b421ef20ad0880ce93b39f1b937ac56f73ff716", ssa_ast = "bd6e87c40965e9f226bb1dc02eec03b4e14a49ba7074dddde28892450e1d8055", flattened_ast = "70ec82dd9d900730d205808c1ddbc5bd518eeff1923affb1ba44bbbaacacdd4a", destructured_ast = "5b84345de4733be9724fa0f7e20c690a27d464b1ce772f6d48e968d1698ecfe5", inlined_ast = "e4c45e5f0b96b26bcb0208c941da8646c6170baecb7da48acc6d033e7e3d4221", dce_ast = "e4c45e5f0b96b26bcb0208c941da8646c6170baecb7da48acc6d033e7e3d4221", bytecode = """ program credits.aleo; record credits: diff --git a/tests/expectations/compiler/futures/nested.out b/tests/expectations/compiler/futures/nested.out index b08dd78da1..04dde9e62d 100644 --- a/tests/expectations/compiler/futures/nested.out +++ b/tests/expectations/compiler/futures/nested.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "0fbe7b86610386bfb1c7f0f211b2043baae706b9195008f8553511968f9297e7", type_checked_symbol_table = "efc3324af11b2f3645010266f1a871d799b81b07bec594fa88402b3f6fe1330b", unrolled_symbol_table = "efc3324af11b2f3645010266f1a871d799b81b07bec594fa88402b3f6fe1330b", initial_ast = "472f984ad224e345de6a6a8cb7c4986b0bf8fa288713c38a506b41bad280faa5", unrolled_ast = "472f984ad224e345de6a6a8cb7c4986b0bf8fa288713c38a506b41bad280faa5", ssa_ast = "ff6501ea72e6a46b15d71a89b71181851fba9aa2e6ee2a36d70218ad1a089a68", flattened_ast = "ba4154876562575fc3f8b6106a3ed4ab331382a4538ebc9630c82ed9be48176b", destructured_ast = "a995365c129f150bc361a571e5a0810f014a62c170d39e904b7de473bcdac50f", inlined_ast = "3a2f11285208b9bd75048be921a23504d9389ae81e2bdc96f631943cfa4349c6", dce_ast = "ed19a1a5455d89e6a59914923e69d600b0fde7fa91cae652d70756eb59365e03", bytecode = """ + { initial_symbol_table = "3349dda351214687b35578120a51581edd42403e912458606d5740d7d29ae4dd", type_checked_symbol_table = "881447243aa23b39575f79716a9f9d9c087d03be1e7bd5f1d09c047725b41329", unrolled_symbol_table = "881447243aa23b39575f79716a9f9d9c087d03be1e7bd5f1d09c047725b41329", initial_ast = "328918d0b3dd6923b30d9ce7404976121e3dd96f32210e9fb514726faef7c2ef", unrolled_ast = "328918d0b3dd6923b30d9ce7404976121e3dd96f32210e9fb514726faef7c2ef", ssa_ast = "a29765973d8c7313f07a01152b5581c3a4a3c1267884e05a7fa16baf4d7eda9a", flattened_ast = "6c44e51bc580168e9f278da0e3a18813f062be0987e0b3011dab7bbdf0194b21", destructured_ast = "6a0ef2c464ec65e4d9f0f4a6d235e8212999712c19f967c6224a67899f42295b", inlined_ast = "2cfb650c684c9932c879bb78fcbc37d602d1ed8068af087b32b0a9e66084e4b1", dce_ast = "86830ad8e03a76f370944f3b12a6fe11ec4db8a520ee7e0e18ab7ec1c4986efb", bytecode = """ program test_dep.aleo; record yeets: diff --git a/tests/expectations/compiler/futures/partial_type_specification.out b/tests/expectations/compiler/futures/partial_type_specification.out index d7df5ae590..e474b75424 100644 --- a/tests/expectations/compiler/futures/partial_type_specification.out +++ b/tests/expectations/compiler/futures/partial_type_specification.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "c3d0ea026b5d60b48e857637a67489b89de75466d257974347c164546b9b9660", type_checked_symbol_table = "ae06cab6240fce0da07873fbf8159dc2acade6e666375b1c52dc586a98a0f8a3", unrolled_symbol_table = "ae06cab6240fce0da07873fbf8159dc2acade6e666375b1c52dc586a98a0f8a3", initial_ast = "6e3dc0ac11741965498701cb2b5ebb68eecb1e932b9f6d84aca33350b91f6e2d", unrolled_ast = "6e3dc0ac11741965498701cb2b5ebb68eecb1e932b9f6d84aca33350b91f6e2d", ssa_ast = "d898f89ce1fbcd93694c06446e31d5ab52ace6fd966c7dd35e082dead74440c7", flattened_ast = "3f8304d2444d4e4132549ae4b530997040c0978d09fc8986bf67a3eba1538e99", destructured_ast = "55c36655c56d82657c07cd352bc12762b12f41a00ca7e8cbf039a4d4d8d6e264", inlined_ast = "b7dda92d9f46b0646ce43f38625e29da41f0273f87990fc0e153cfe61e992523", dce_ast = "638d72b2d6010f5a2a7d699fb69b1a056faae9a878b3c37f2b34e8f41fad5176", bytecode = """ + { initial_symbol_table = "1b2267ab51efd673df88dcb1eeb1ec2906e074ced7686a6b1a42bd4bd3c2dfec", type_checked_symbol_table = "2db56bd7d4d5e1aab3a8985500c4e312dffd0c1b494c3aee7517ae2659921ade", unrolled_symbol_table = "2db56bd7d4d5e1aab3a8985500c4e312dffd0c1b494c3aee7517ae2659921ade", initial_ast = "097f10d87647d844617c056c30f24c84d7c8f1ce039dcdffcd43087e5f03c071", unrolled_ast = "097f10d87647d844617c056c30f24c84d7c8f1ce039dcdffcd43087e5f03c071", ssa_ast = "1e22ea418facff5d568b7990eccf47d9c673fe73836619271b05da0aa7c22b4a", flattened_ast = "e6b6643bf7a2f42f2352cd36adb8bf1c783501cdab10b0b8e44e58941d65b373", destructured_ast = "7a93fc18087bdafe80684129998d2343533777c70127b223e2500dd799da776f", inlined_ast = "bcfef5f41213095660d8311021847eecf0d139a470ab5007a80e9c830b812c5b", dce_ast = "99e24cb567629f64e67eab746a07afdcf3b9c0f3650f91de04b04386d38cfccd", bytecode = """ program test_dep.aleo; record yeets: diff --git a/tests/expectations/compiler/group/mult_by_group_fail.out b/tests/expectations/compiler/group/mult_by_group_fail.out index 685375e5f1..6984add261 100644 --- a/tests/expectations/compiler/group/mult_by_group_fail.out +++ b/tests/expectations/compiler/group/mult_by_group_fail.out @@ -1,11 +1,13 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372007]: Expected one type from `scalar`, but got `group` - --> compiler-test:5:30 +Error [ETYC0372120]: Received types `group` and `group` for the operation `*`. + --> compiler-test:5:16 | 5 | return (_, _)group * a; - | ^ + | ^^^^^^^^^^^^^^^ + | + = Valid operands are two integers of the same type, two fields, or a scalar and a group. Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/mappings/read_external_mapping.out b/tests/expectations/compiler/mappings/read_external_mapping.out index 5d999a9f76..9395d51b6e 100644 --- a/tests/expectations/compiler/mappings/read_external_mapping.out +++ b/tests/expectations/compiler/mappings/read_external_mapping.out @@ -24,7 +24,7 @@ finalize unregister: input r0 as address.public; set false into users[r0]; """, errors = "", warnings = "" }, - { initial_symbol_table = "ad44035dc7b8fd88c75dae7732786222905037adcba313f1fa11964e3b6a3a18", type_checked_symbol_table = "2ae36cf87aea22ac6069d3d750ea3ed2b2ac03c0f9ee75f957edf106095aa036", unrolled_symbol_table = "2ae36cf87aea22ac6069d3d750ea3ed2b2ac03c0f9ee75f957edf106095aa036", initial_ast = "9cc519cc416b2f54ecf753c541196b337f359d42616e4f38b8d9a5a86746de41", unrolled_ast = "4f5beff4969ba9db8b429435d2a6a6133eed2e8718564073fefa76ed4db76381", ssa_ast = "012d0c07475a7e03d3898338aa2a91b56d77032978437b17c9337a5001ae5249", flattened_ast = "e391d1d2c6731ec8961afe91d8fa94fb9edb091b892ddecfa48ce3f5a6febe8e", destructured_ast = "26f202a3d6a24f0af49542d0f2c29c635314073b2d52ede163d3ab5e5bcc86fa", inlined_ast = "72e4121a823f91aeeb5b8433f03f07943d174353d55f58a3aae111bc1bab0798", dce_ast = "72e4121a823f91aeeb5b8433f03f07943d174353d55f58a3aae111bc1bab0798", bytecode = """ + { initial_symbol_table = "72d46f715cf58eb2b97ff5cef4d8768700a37ae70374ce8eaafefae584ee527f", type_checked_symbol_table = "6795691d2471fda8328ef3938cd620225e095fa947c0468959670c0feeff7d24", unrolled_symbol_table = "6795691d2471fda8328ef3938cd620225e095fa947c0468959670c0feeff7d24", initial_ast = "c6961c7b70fb87a56e44c31d0dc98a21924f0ba72b5cebb9badd6836b5eab56e", unrolled_ast = "40f00aa24c4981d9f54633125ee4e7fb323e15dc4686bb2aec54f9195c5af28f", ssa_ast = "cf58ef07b395655efb8a3b6e2f376c5295e3718091b34128530bcb27e8ea0f42", flattened_ast = "23b1e3eb3e2f5d813322829acd16d8d57f5bc57ba8264b3c00269ef1d24f6cbe", destructured_ast = "bf8920a358ffe1ded495d69c109404f8b110f601924aac332e741e0f9d4e0391", inlined_ast = "f3a8e1bd8096d7e67466bcf83d4f20785b1ac152728e6666a92888d6acb21391", dce_ast = "f3a8e1bd8096d7e67466bcf83d4f20785b1ac152728e6666a92888d6acb21391", bytecode = """ import registry.aleo; program relay.aleo; diff --git a/tests/expectations/compiler/mappings/variable_shadow_mapping_fail.out b/tests/expectations/compiler/mappings/variable_shadow_mapping_fail.out index 728171d9b8..74b1b7189f 100644 --- a/tests/expectations/compiler/mappings/variable_shadow_mapping_fail.out +++ b/tests/expectations/compiler/mappings/variable_shadow_mapping_fail.out @@ -6,7 +6,7 @@ Error [EAST0372009]: variable `m` shadowed by | 7 | let m: u8 = 1u8; | ^ -Error [ETYC0372003]: Expected type `u8` but type `(u8 => u8)` was found +Error [ETYC0372117]: Expected type `u8` but type `(u8 => u8)` was found. --> compiler-test:8:16 | 8 | return m; diff --git a/tests/expectations/compiler/operations/abs_type_fail.out b/tests/expectations/compiler/operations/abs_type_fail.out new file mode 100644 index 0000000000..40cd24ddcc --- /dev/null +++ b/tests/expectations/compiler/operations/abs_type_fail.out @@ -0,0 +1,14 @@ +namespace = "Compile" +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected a signed integer but type `u16` was found. + --> compiler-test:5:24 + | + 5 | return (true ? 1u16.abs() : 2u16.abs()) as u8; + | ^^^^^^^^^^ +Error [ETYC0372117]: Expected a signed integer but type `u16` was found. + --> compiler-test:5:37 + | + 5 | return (true ? 1u16.abs() : 2u16.abs()) as u8; + | ^^^^^^^^^^ +"""] diff --git a/tests/expectations/compiler/operations/add_type_fail.out b/tests/expectations/compiler/operations/add_type_fail.out new file mode 100644 index 0000000000..3cfe1acea2 --- /dev/null +++ b/tests/expectations/compiler/operations/add_type_fail.out @@ -0,0 +1,14 @@ +namespace = "Compile" +expectation = "Fail" +outputs = [""" +Error [ETYC0372117]: Expected a field, group, scalar, or integer but type `bool` was found. + --> compiler-test:5:17 + | + 5 | return (true + false) as u8; + | ^^^^ +Error [ETYC0372117]: Expected a field, group, scalar, or integer but type `bool` was found. + --> compiler-test:5:24 + | + 5 | return (true + false) as u8; + | ^^^^^ +"""] diff --git a/tests/expectations/compiler/records/duplicate_circuit_name_fail.out b/tests/expectations/compiler/records/duplicate_circuit_name_fail.out index 2813782684..1d318eb21a 100644 --- a/tests/expectations/compiler/records/duplicate_circuit_name_fail.out +++ b/tests/expectations/compiler/records/duplicate_circuit_name_fail.out @@ -1,11 +1,11 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372083]: A program must have at least one transition function. - --> compiler-test:1:1 +Error [EAST0372008]: record `Token` shadowed by + --> compiler-test:11:5 | - 1 | - 2 | - 3 | program test.aleo { - | ^^^^^^^^^^^^ + 11 | struct Token { // This struct cannot have the same name as the record defined above it. + 12 | x: u32, + 13 | } + | ^ """] diff --git a/tests/expectations/compiler/records/external_nested_record.out b/tests/expectations/compiler/records/external_nested_record.out index 9000a4c89c..a89644a0b4 100644 --- a/tests/expectations/compiler/records/external_nested_record.out +++ b/tests/expectations/compiler/records/external_nested_record.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "b59a64e702cf908299e322a302bbff0b310c263353e4e2d40ac9c2cf55014e35", type_checked_symbol_table = "0de9af52dc5b3b905b76c91bfeecc8f18ec3888395e81acf47f377599a044a23", unrolled_symbol_table = "0de9af52dc5b3b905b76c91bfeecc8f18ec3888395e81acf47f377599a044a23", initial_ast = "0603c5de85d72aff1b82ae064e9f056a5a12f4a3c9a43b7110245f71ab184179", unrolled_ast = "0603c5de85d72aff1b82ae064e9f056a5a12f4a3c9a43b7110245f71ab184179", ssa_ast = "0603c5de85d72aff1b82ae064e9f056a5a12f4a3c9a43b7110245f71ab184179", flattened_ast = "b8253c762a2456d82dd47c27018cac6d44083a9eaafafcd60e1b83f8b0d16aa1", destructured_ast = "900c4b9018194c85f2ca523cb559f9f597265d3a23d410a757017cd803fbffb1", inlined_ast = "900c4b9018194c85f2ca523cb559f9f597265d3a23d410a757017cd803fbffb1", dce_ast = "900c4b9018194c85f2ca523cb559f9f597265d3a23d410a757017cd803fbffb1", bytecode = """ + { initial_symbol_table = "b78bb702e943b32f2bdb6e00bd077028816c5b7c39edf25e90d1e13d566a954b", type_checked_symbol_table = "146445e74d6de5ae33c8dffcbc1f11d1ee55f9a3909ea0b23a130c35a342e7af", unrolled_symbol_table = "146445e74d6de5ae33c8dffcbc1f11d1ee55f9a3909ea0b23a130c35a342e7af", initial_ast = "48ce3a7bae5585b65a9e90bff61fab17c1374bca0e87cab1b5c3f2c185f450dc", unrolled_ast = "48ce3a7bae5585b65a9e90bff61fab17c1374bca0e87cab1b5c3f2c185f450dc", ssa_ast = "48ce3a7bae5585b65a9e90bff61fab17c1374bca0e87cab1b5c3f2c185f450dc", flattened_ast = "29d625fb72c41e5fd8ad3514624b97b85a1ae3939db5a4d7b378d5c13f00005b", destructured_ast = "b466efabe7243c7fbefc902e50cd94dcdb026d454f0481050c84977213867d0c", inlined_ast = "b466efabe7243c7fbefc902e50cd94dcdb026d454f0481050c84977213867d0c", dce_ast = "b466efabe7243c7fbefc902e50cd94dcdb026d454f0481050c84977213867d0c", bytecode = """ program child.aleo; record child_rec: diff --git a/tests/expectations/compiler/records/gates_is_allowed.out b/tests/expectations/compiler/records/gates_is_allowed.out index c400c758e7..2151789488 100644 --- a/tests/expectations/compiler/records/gates_is_allowed.out +++ b/tests/expectations/compiler/records/gates_is_allowed.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "7b7370a95949739bbb1b6fa3139ba90670c42d68eac051eaabfe4aa759775481", type_checked_symbol_table = "c0de0856800efab5e0591eda8ac78e3bfe858a9205d46401a07a0c91077767a9", unrolled_symbol_table = "c0de0856800efab5e0591eda8ac78e3bfe858a9205d46401a07a0c91077767a9", initial_ast = "655e847661250ba3937f6419a9d920797a794cad63feb65196bec00d658234fe", unrolled_ast = "655e847661250ba3937f6419a9d920797a794cad63feb65196bec00d658234fe", ssa_ast = "5e28e91d5318baefa8d55e6817659de0c72416b7fdb8ef77df5e4e3a5703b8d1", flattened_ast = "03ae9b01404a08345cc315de9d11190899294a8b7970fffa9296a0d2f6e5e11f", destructured_ast = "056366508d4a248cd4ed6fb04a69efbb07f6f79ffc889f872afd5e1279785e96", inlined_ast = "056366508d4a248cd4ed6fb04a69efbb07f6f79ffc889f872afd5e1279785e96", dce_ast = "056366508d4a248cd4ed6fb04a69efbb07f6f79ffc889f872afd5e1279785e96", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "ff73c314ef4e32d8b41c285e6148e39512353da9510387005470c428c59269ba", type_checked_symbol_table = "cfb866ee1f77c7461d5ceee549247ea7edd70f27d048866a290dcb99bbba56d6", unrolled_symbol_table = "cfb866ee1f77c7461d5ceee549247ea7edd70f27d048866a290dcb99bbba56d6", initial_ast = "129ac40f7951e7bb74a70fd63d81feab0922aacb25495122e15e12791fc94410", unrolled_ast = "129ac40f7951e7bb74a70fd63d81feab0922aacb25495122e15e12791fc94410", ssa_ast = "411d0f9638f6236f4810e4cc365b8c1bb1eac3a06a97e264242fdf56d5be6475", flattened_ast = "056a794fb5fb8daa8f50710b7eb3ad5ac31ec039a9887d709162d4c6f142195a", destructured_ast = "617f4bc3b37aa8e71c5def628bd3c717988627cda1e52b366c1e74ace085a92a", inlined_ast = "617f4bc3b37aa8e71c5def628bd3c717988627cda1e52b366c1e74ace085a92a", dce_ast = "617f4bc3b37aa8e71c5def628bd3c717988627cda1e52b366c1e74ace085a92a", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/compiler/records/init_expression.out b/tests/expectations/compiler/records/init_expression.out index 4277a5c0e9..14fa81942e 100644 --- a/tests/expectations/compiler/records/init_expression.out +++ b/tests/expectations/compiler/records/init_expression.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "3fd1cc6a2ce3920f6a8669981cc229d991818bc1baa451da4f15c15182445a80", type_checked_symbol_table = "ca911d7fe1163c60a9cfb288fcb2863dc9cac2f114ff4c48d8aff5bd82908159", unrolled_symbol_table = "ca911d7fe1163c60a9cfb288fcb2863dc9cac2f114ff4c48d8aff5bd82908159", initial_ast = "8160dc0cbe7e1bc57e65f46d78222c56e3ec7f1786a31c18adf1705985b25365", unrolled_ast = "8160dc0cbe7e1bc57e65f46d78222c56e3ec7f1786a31c18adf1705985b25365", ssa_ast = "8b9a5676e89823fa5d8b88ddad56f8fe2f518910cec99abc3ceb026cc0692d27", flattened_ast = "da220e2edfb44d1e871b010cfe2663e40e06e3c71c472710f781dd2c585e2184", destructured_ast = "9e1726ad46b3ee2de7496cf5f834127ad440b59b76f8ec9c69b3ac733c61bd36", inlined_ast = "9e1726ad46b3ee2de7496cf5f834127ad440b59b76f8ec9c69b3ac733c61bd36", dce_ast = "69b116454ce349eb479f08eebd42729a9284642d664c83ac65cfa86f2e1309c2", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "15f2ecfaffc3674b5c37c548dc8180fbbefaa80bb8a62e8794e52da624102054", type_checked_symbol_table = "b7462fae8d09e55b260346ce02616eb894136ba4c0d4b0a185f775a44e77c64e", unrolled_symbol_table = "b7462fae8d09e55b260346ce02616eb894136ba4c0d4b0a185f775a44e77c64e", initial_ast = "310149548a9efb068d208e0e6e0595c63fc6fef77fea04c7d53e0a2c5fa263e3", unrolled_ast = "310149548a9efb068d208e0e6e0595c63fc6fef77fea04c7d53e0a2c5fa263e3", ssa_ast = "d8c30ca374c55d961a94e5ee5fa30ff3fd1c761fa13dc526c940d9b38590ec2d", flattened_ast = "762eecfca3d51ab14e1159d67b5e38d73aafb525f5ea0b6897c82d3ca3590673", destructured_ast = "4a1067062cac5f8a907d63946ad00d45cba3b67b19ec56e552d71039ecb9c6d6", inlined_ast = "4a1067062cac5f8a907d63946ad00d45cba3b67b19ec56e552d71039ecb9c6d6", dce_ast = "47d6ee1ecd0eef9090a3dfa79864d89b59cf65c63126aba40a8444cbce9c91be", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/compiler/records/init_expression_shorthand.out b/tests/expectations/compiler/records/init_expression_shorthand.out index 323bd8102c..3765a33d2f 100644 --- a/tests/expectations/compiler/records/init_expression_shorthand.out +++ b/tests/expectations/compiler/records/init_expression_shorthand.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "002e762d77a8521f1679eab9904bf7357422d0fa74a5ac1b3652a90ad588c0bb", type_checked_symbol_table = "833e07fbb1a747d1575ee49268dc2948de1475fed19731cd8083a23d0231c605", unrolled_symbol_table = "833e07fbb1a747d1575ee49268dc2948de1475fed19731cd8083a23d0231c605", initial_ast = "3917e2251c71ec95bbb6cf5731dcf43126aafa4115a3b2a7767c1a0b1aa70eb6", unrolled_ast = "923de60415b7eb88a8ba42c16c831e73fb586d1c46599f85aafc8d69b6920033", ssa_ast = "3fda30235b60f942f2ce28e0b32749e04924c5b226e78a2184cdaa3b36b3a2ee", flattened_ast = "b4a27bb564c16bac85dbafbc00a4c4c47350b04d2b0fef002efd7b8ecc1def36", destructured_ast = "58ec5e057d5129e2db6d8f699eae5a5d061d4fe62fb7878c84f94f67ee47ebf9", inlined_ast = "58ec5e057d5129e2db6d8f699eae5a5d061d4fe62fb7878c84f94f67ee47ebf9", dce_ast = "a9f2a052ca981a5a23ce47ba13c410311e10d5fc87f2648ba62f850a8a2d5c6e", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "8b69449a3d79e334ca8cb76ce7055bb9b0d2fd5efffcc244c7e2b90e21fae704", type_checked_symbol_table = "378c0f749b7f784e8d460eaf9a9327551c769a0bda120ac5b8a5f425de0815b9", unrolled_symbol_table = "378c0f749b7f784e8d460eaf9a9327551c769a0bda120ac5b8a5f425de0815b9", initial_ast = "c4ccf89c456f4aef33bbe9239b824ae698226885af8935b9e5172e82ac0fe928", unrolled_ast = "3e0db3feedebeff2aa27af0a5351066318e1ef15c1abda067dbde2bb5880bc5f", ssa_ast = "84accb8e0b4480dfbbda50fe3f5a56b1cf36c3ccb2b2a0ad6f729343f7b3398c", flattened_ast = "28e392dbc3203db47447a9a9a9f427acce5a84425e476ee8902a7748d80e1adb", destructured_ast = "872991dcf78bfdf1de9e01bfc9b11da44c583f470a146aae980d5b0ca383a8d0", inlined_ast = "872991dcf78bfdf1de9e01bfc9b11da44c583f470a146aae980d5b0ca383a8d0", dce_ast = "88a0c7699fa49283bc5bcd321946363a038b4013eb1caae687db707dbf439f88", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/compiler/records/init_expression_type_fail.out b/tests/expectations/compiler/records/init_expression_type_fail.out index 35997f01e3..6059ec5ce9 100644 --- a/tests/expectations/compiler/records/init_expression_type_fail.out +++ b/tests/expectations/compiler/records/init_expression_type_fail.out @@ -11,12 +11,12 @@ Error [ETYC0372057]: Only `transition` functions can have a record as input or o | 11 | function mint(r0: address, r1: u64) -> Token { | ^^^^^ -Error [ETYC0372003]: Expected type `address` but type `u64` was found +Error [ETYC0372117]: Expected type `address` but type `u64` was found. --> compiler-test:13:20 | 13 | owner: r1, // This variable should be type address. | ^^ -Error [ETYC0372003]: Expected type `u64` but type `address` was found +Error [ETYC0372117]: Expected type `u64` but type `address` was found. --> compiler-test:14:21 | 14 | amount: r0, // This variable should be type u64. diff --git a/tests/expectations/compiler/records/nested_record.out b/tests/expectations/compiler/records/nested_record.out index 949e4c6d8f..d1521ce320 100644 --- a/tests/expectations/compiler/records/nested_record.out +++ b/tests/expectations/compiler/records/nested_record.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "5b8c5b2a0876c74dc30026b2f2b559851bed7fd78570aca2d73ff6bf6f6b978f", type_checked_symbol_table = "494c29aaab2d05abfc510da4877b5c111d765c8dc7408436b6e1b2f0e5a3a905", unrolled_symbol_table = "494c29aaab2d05abfc510da4877b5c111d765c8dc7408436b6e1b2f0e5a3a905", initial_ast = "ce249307b5be89ebd81d36aea76c5563a1bf06d8abc410a7efdaf5d42fc9c8e1", unrolled_ast = "ce249307b5be89ebd81d36aea76c5563a1bf06d8abc410a7efdaf5d42fc9c8e1", ssa_ast = "a3ef314961cd5905bfba1087318a02acf3ba098a373fc0a6fd8fdf3f5b1ebd14", flattened_ast = "4fc89fc15a0c119400a045fd7a2809a811f82634e71c624729154e17956367f8", destructured_ast = "00db00056443bc6d46a70373f3f22b51ffc5bc724314b2314a3bf1f7fc6ec69c", inlined_ast = "00db00056443bc6d46a70373f3f22b51ffc5bc724314b2314a3bf1f7fc6ec69c", dce_ast = "e25a6bd09d054c3f041c70e6c4013b1269fdba734e6e78f35c3b69dd8c4ce2d0", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "f3f54a41937d9ce78329511875eb9d2af4407d37217ff8207691058f66b27b03", type_checked_symbol_table = "be6906bf7584a6e05cef12b96d9af9a83d9855b5a3223f478a0c9bf08a01f28e", unrolled_symbol_table = "be6906bf7584a6e05cef12b96d9af9a83d9855b5a3223f478a0c9bf08a01f28e", initial_ast = "d863e7b59dfe59fcd0ba922249e2eb0c315fc73b7fe6d42e958e0dbbac1f2340", unrolled_ast = "d863e7b59dfe59fcd0ba922249e2eb0c315fc73b7fe6d42e958e0dbbac1f2340", ssa_ast = "8814d0124a22f34914389617e5b5e75fe5dc6e0008f7412b086725c118d1af53", flattened_ast = "30d106f24bf58d609adff9f463554e3b2746d2e7447023be0847c3a0055fef81", destructured_ast = "5a9ab78d59ef7449107dcbe49732893c39f6ab044d36bbc3eb8ea3ef13e6777f", inlined_ast = "5a9ab78d59ef7449107dcbe49732893c39f6ab044d36bbc3eb8ea3ef13e6777f", dce_ast = "7587e75f6c122fb5be51187ba59091638358c816d1dce87689f1284cd1be8788", bytecode = """ program test.aleo; struct Amount: diff --git a/tests/expectations/compiler/records/nested_record_as_function_io.out b/tests/expectations/compiler/records/nested_record_as_function_io.out index 6400b34a1f..310f0e6101 100644 --- a/tests/expectations/compiler/records/nested_record_as_function_io.out +++ b/tests/expectations/compiler/records/nested_record_as_function_io.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "c953e3bff6aadcc83960d916ee9cfed52a14318806f8aa98df5f2852d37cbc6e", type_checked_symbol_table = "e36903969c31dc13732b73e6f9b2f0dab5cd8e5ae16984e414047e68edd27f06", unrolled_symbol_table = "e36903969c31dc13732b73e6f9b2f0dab5cd8e5ae16984e414047e68edd27f06", initial_ast = "c870708760c403e0e46ff83e7d74f3c4eb216d8c491edd71ff0459f117cbbdc3", unrolled_ast = "c870708760c403e0e46ff83e7d74f3c4eb216d8c491edd71ff0459f117cbbdc3", ssa_ast = "d0127391d923a2c9fbcd0f01cb20c3337801426a595a644ec840d2dec8d71aa6", flattened_ast = "99981748c19be5ec946d6786bb8c61056a2c0c89006cc256784ff55aad16d092", destructured_ast = "a5ccb0b7d744595e5b7d5c141b6b8bb057e395db63f34a7b9c02d6a3400810f5", inlined_ast = "a5ccb0b7d744595e5b7d5c141b6b8bb057e395db63f34a7b9c02d6a3400810f5", dce_ast = "a5ccb0b7d744595e5b7d5c141b6b8bb057e395db63f34a7b9c02d6a3400810f5", bytecode = """ + { initial_symbol_table = "d511d5e8e5cb5c8c3f44a5f7ce92aab56b90c3919ac52150dff0f8134fcb22a4", type_checked_symbol_table = "bea19f6fcf333c1348e7c7822acd9a0289321f7dca0c084e32dab07cd7c57987", unrolled_symbol_table = "bea19f6fcf333c1348e7c7822acd9a0289321f7dca0c084e32dab07cd7c57987", initial_ast = "b64182a25ffce908c6ed2a904e9e294603e8cb603de9aaeb73668e1a8cbbf5d0", unrolled_ast = "b64182a25ffce908c6ed2a904e9e294603e8cb603de9aaeb73668e1a8cbbf5d0", ssa_ast = "528aa2e48a0930f37ba4e90ac96aaa1cf0fb86635263446f5378e4dfa43d41fd", flattened_ast = "9428b742d8d262b97984cecf88806b1d369d2713b30a1ea3923e62236e04a1fe", destructured_ast = "509bff06f2ebce0396b4857413307e17e79e20f379d1900f140408217ae9c8f9", inlined_ast = "509bff06f2ebce0396b4857413307e17e79e20f379d1900f140408217ae9c8f9", dce_ast = "509bff06f2ebce0396b4857413307e17e79e20f379d1900f140408217ae9c8f9", bytecode = """ program program_a.aleo; record X: diff --git a/tests/expectations/compiler/records/record_declaration_out_of_order.out b/tests/expectations/compiler/records/record_declaration_out_of_order.out index 6dd5bf14b4..50c43da9fe 100644 --- a/tests/expectations/compiler/records/record_declaration_out_of_order.out +++ b/tests/expectations/compiler/records/record_declaration_out_of_order.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "3f9924dd0dd047baffbbd264bff45deeeb9c7f0e5b85cec1f09d368ccf2da34d", type_checked_symbol_table = "b63238fe925dc148180f075a969645f67188ebf518232f630a7c84c8d9fd68a2", unrolled_symbol_table = "b63238fe925dc148180f075a969645f67188ebf518232f630a7c84c8d9fd68a2", initial_ast = "0b156106d2f50efe97476dfdd1f07741b2db336c50cfd89113c0eb011b718ea6", unrolled_ast = "0b156106d2f50efe97476dfdd1f07741b2db336c50cfd89113c0eb011b718ea6", ssa_ast = "53c908cf360f5469c561d84a7fc021d985a9cf5e9ed8dc050b0d3937339f14ab", flattened_ast = "bfff4d02525394ef7e29496626789c64dbf4f8b92810fbc79ba38faef114ae69", destructured_ast = "d539c3593943275cd7f4eb2dde377d0be520c64a2d15a00e41ad7242068ffd68", inlined_ast = "d539c3593943275cd7f4eb2dde377d0be520c64a2d15a00e41ad7242068ffd68", dce_ast = "d539c3593943275cd7f4eb2dde377d0be520c64a2d15a00e41ad7242068ffd68", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "ac00608e73c1c301c5422ec9434e16cfc9ff32984691b06e450afd1cde6fd395", type_checked_symbol_table = "118af94c6edb338dd5daec53b36ecdda83275b60aadca91907c84a6c9c089e13", unrolled_symbol_table = "118af94c6edb338dd5daec53b36ecdda83275b60aadca91907c84a6c9c089e13", initial_ast = "e8986cfdca90fee487bf8f984f6b3f7aeac2dbd312559a3f4f017d3f487cc39a", unrolled_ast = "e8986cfdca90fee487bf8f984f6b3f7aeac2dbd312559a3f4f017d3f487cc39a", ssa_ast = "e6c4ef70820b71babfec205ab842b1e8ef9fa66c9dcac1934479916a6b2b1a1c", flattened_ast = "543ae1d1bae6830181baca181e3d7d10dd2b722efa3477f4aaf8508827e1acff", destructured_ast = "4d657459e4abb30b287a673015de4dc1288b46953449308b222151d5b4db93c2", inlined_ast = "4d657459e4abb30b287a673015de4dc1288b46953449308b222151d5b4db93c2", dce_ast = "4d657459e4abb30b287a673015de4dc1288b46953449308b222151d5b4db93c2", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/compiler/records/record_init_out_of_order.out b/tests/expectations/compiler/records/record_init_out_of_order.out index 4688796a09..32831c5c7f 100644 --- a/tests/expectations/compiler/records/record_init_out_of_order.out +++ b/tests/expectations/compiler/records/record_init_out_of_order.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "6feca07193b306037d0a93baef8f35b166890e11fb15af517d5f5c424c0840ca", type_checked_symbol_table = "e084cc1575d2853a823d08df5615028b18a39cc1b839ae41ac46f305cf5af81d", unrolled_symbol_table = "e084cc1575d2853a823d08df5615028b18a39cc1b839ae41ac46f305cf5af81d", initial_ast = "0f4e4004f2763ca95cc6d9ea35a30157f8b6f8453126065697cbe334e34144f3", unrolled_ast = "0e01d06487035888e2f16e325cf5d40f8999eed94ff22d0ca6f8da1f7154e461", ssa_ast = "09da4292294f513073a69a66e3a8478973affe50ea7d426e6161a3a9afe8af62", flattened_ast = "fb24e616b49908385cbe1fd252847b8c0e92147cc206bc11f9fb1f29e5721e1e", destructured_ast = "237ed96bfc2bcb15043481d52b1a8c1ebaf9337803c67eb3a3ab4fd169dd7454", inlined_ast = "237ed96bfc2bcb15043481d52b1a8c1ebaf9337803c67eb3a3ab4fd169dd7454", dce_ast = "237ed96bfc2bcb15043481d52b1a8c1ebaf9337803c67eb3a3ab4fd169dd7454", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "05408511204fb80003aaf21565964536876e6d51b2110332dd7a2f9ee3bd45a1", type_checked_symbol_table = "a2fbb69ead3d113bcf68340adfbcea86181709031d6f6b9592ca7fe0cab93eb9", unrolled_symbol_table = "a2fbb69ead3d113bcf68340adfbcea86181709031d6f6b9592ca7fe0cab93eb9", initial_ast = "18290b69b1442dec9bcc309d17b3b0e0b43fd091bfd673a002171be339094901", unrolled_ast = "bd44d436d9767dcb37c16571c94540f1d9684cc80ea40fb5070ad148cd1a5c74", ssa_ast = "d10574460f9bf02504e84ac4f669d6af257e0331afce6752afb9b5d34fdf4831", flattened_ast = "6b74732354a381385d1f4b8d8a0801a6d1b15fc7ab92b52595349bcee7ae3f61", destructured_ast = "637d3d2c7b6df2fec7f9c89febba89e990576d4d76a6d503c9e3dfdaaa7ef87a", inlined_ast = "637d3d2c7b6df2fec7f9c89febba89e990576d4d76a6d503c9e3dfdaaa7ef87a", dce_ast = "637d3d2c7b6df2fec7f9c89febba89e990576d4d76a6d503c9e3dfdaaa7ef87a", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/compiler/records/record_with_visibility.out b/tests/expectations/compiler/records/record_with_visibility.out index aa679606a9..18a4b5c7d8 100644 --- a/tests/expectations/compiler/records/record_with_visibility.out +++ b/tests/expectations/compiler/records/record_with_visibility.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "4399efef323bcfeaa73dd0b4a290600d5d85e36cf99c5d6ffb4fcb3ea59353a3", type_checked_symbol_table = "20557e7ee74980978625fbd09ed9defc27cc1657ebd95dec0d88a34f80fcf73c", unrolled_symbol_table = "20557e7ee74980978625fbd09ed9defc27cc1657ebd95dec0d88a34f80fcf73c", initial_ast = "02e791ec58d79b95c1dcd9eaad1fccc95c503995a5ef053c45fe4d4d71025458", unrolled_ast = "02e791ec58d79b95c1dcd9eaad1fccc95c503995a5ef053c45fe4d4d71025458", ssa_ast = "98f1a58e417e30e98196535b5ab67f80a47c00e2fa3ac8136fb6918d7d13ecd6", flattened_ast = "1473c921dc87393d1bec2cd3469f66c642909f87032fbfb4fdec7db088a07df3", destructured_ast = "cfd232d35ee8cd3768e4924eb4e438a62ad3a04e3df77844c3354aac907a6350", inlined_ast = "cfd232d35ee8cd3768e4924eb4e438a62ad3a04e3df77844c3354aac907a6350", dce_ast = "cfd232d35ee8cd3768e4924eb4e438a62ad3a04e3df77844c3354aac907a6350", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "4e63c5c64c9e469d434a108ea84bfbb44187dbb684ac254f148dc3e18b0b5d97", type_checked_symbol_table = "1bc7f6fb83b3d59b5fd87ac63a9b6fdb8664bddf8af61906da645172d0c68142", unrolled_symbol_table = "1bc7f6fb83b3d59b5fd87ac63a9b6fdb8664bddf8af61906da645172d0c68142", initial_ast = "fb54bacd49c386a9f2fdf1e04c1935a49adb221ebf8e1231b208d1e5ad7d34a3", unrolled_ast = "fb54bacd49c386a9f2fdf1e04c1935a49adb221ebf8e1231b208d1e5ad7d34a3", ssa_ast = "99e1098efdd2817c126310b1774b7535820c26a6faf467ecb9ef0207a275d722", flattened_ast = "72c6f35164038efa2e94a3967fbb134f810b41ee531e6165532bc6131bde9dba", destructured_ast = "93d5a3aec473ac4fdd27daa99c02ca12e782b72306db1b1d840d348986334017", inlined_ast = "93d5a3aec473ac4fdd27daa99c02ca12e782b72306db1b1d840d348986334017", dce_ast = "93d5a3aec473ac4fdd27daa99c02ca12e782b72306db1b1d840d348986334017", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/compiler/records/return_record_instead_of_unit_fail.out b/tests/expectations/compiler/records/return_record_instead_of_unit_fail.out index 9c2bc3560b..2cec826f36 100644 --- a/tests/expectations/compiler/records/return_record_instead_of_unit_fail.out +++ b/tests/expectations/compiler/records/return_record_instead_of_unit_fail.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `()` but type `test_credits` was found +Error [ETYC0372117]: Expected type `()` but type `test_credits` was found. --> compiler-test:10:16 | 10 | return test_credits { diff --git a/tests/expectations/compiler/records/same_name_diff_type_fail.out b/tests/expectations/compiler/records/same_name_diff_type_fail.out new file mode 100644 index 0000000000..d514771fb0 --- /dev/null +++ b/tests/expectations/compiler/records/same_name_diff_type_fail.out @@ -0,0 +1,11 @@ +namespace = "Compile" +expectation = "Fail" +outputs = [""" +Error [ETYC0372119]: Received different types `R` and `child.aleo/R` for the operation `==`. + --> compiler-test:16:16 + | + 16 | return r1 == child.aleo/create(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = Make both operands the same type. +"""] diff --git a/tests/expectations/compiler/scalar/div_fail.out b/tests/expectations/compiler/scalar/div_fail.out index 5dfacd4812..8cb218346e 100644 --- a/tests/expectations/compiler/scalar/div_fail.out +++ b/tests/expectations/compiler/scalar/div_fail.out @@ -1,11 +1,16 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372007]: Expected one type from `field, i8, i16, i32, i64, i128, u8, u16, u32, u64, u128`, but got `scalar` +Error [ETYC0372117]: Expected a field or integer but type `scalar` was found. --> compiler-test:5:16 | 5 | return a / b; // division not supported for scalar types. - | ^^^^^ + | ^ +Error [ETYC0372117]: Expected a field or integer but type `scalar` was found. + --> compiler-test:5:20 + | + 5 | return a / b; // division not supported for scalar types. + | ^ Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/scalar/square_root_fail.out b/tests/expectations/compiler/scalar/square_root_fail.out index 88efaf977e..879d11dc37 100644 --- a/tests/expectations/compiler/scalar/square_root_fail.out +++ b/tests/expectations/compiler/scalar/square_root_fail.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372007]: Expected one type from `field`, but got `scalar` +Error [ETYC0372117]: Expected type `field` but type `scalar` was found. --> compiler-test:5:16 | 5 | return a.square_root(); // square root not supported for scalar types. diff --git a/tests/expectations/compiler/signature/signature.out b/tests/expectations/compiler/signature/signature.out index 72dad77eb7..4145c9f78c 100644 --- a/tests/expectations/compiler/signature/signature.out +++ b/tests/expectations/compiler/signature/signature.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "70a3be0d7dcfa274581f374e661b48f26ed51cb4532c9566e0de9d76eb8c1cb9", type_checked_symbol_table = "0a541ea8d67a3cab711d7ec8cb1cf264c1ec58c5a08d43efb9970b38b37f2260", unrolled_symbol_table = "0a541ea8d67a3cab711d7ec8cb1cf264c1ec58c5a08d43efb9970b38b37f2260", initial_ast = "eaba8c7e44dacd5223292622bdb6d6f372dea1d9d113f091fbcfc8b61ca96039", unrolled_ast = "eaba8c7e44dacd5223292622bdb6d6f372dea1d9d113f091fbcfc8b61ca96039", ssa_ast = "1d8578ea33d84f2462b0d59ed44801a07f335a64596b919926e921943324f821", flattened_ast = "e557a38874f1309f1096546ebfb13100af7770ca3c43bdf1d6b473e7ea0d803b", destructured_ast = "5b538c9ed88a40b1edd4637f54285fdd57c6ff958eadcba54df999d8ead20f3d", inlined_ast = "5b538c9ed88a40b1edd4637f54285fdd57c6ff958eadcba54df999d8ead20f3d", dce_ast = "2949f1e4a4122944d8290090c64803da4b01a906ae80f638bfc1ec476c532c9b", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "0fdc7772b4625c9d47277475bb25ad86c03fe9ca5fced98117a2cb621af80f74", type_checked_symbol_table = "4aae1c908788da7ba8f4b2b34f4662646ee4adf80d0bce8f267a2d9393a5726f", unrolled_symbol_table = "4aae1c908788da7ba8f4b2b34f4662646ee4adf80d0bce8f267a2d9393a5726f", initial_ast = "bc6d2d3a89e0fe70e79a72f2818a8fa8d3b6b15887da7a85400e4d2ed7cf34e8", unrolled_ast = "bc6d2d3a89e0fe70e79a72f2818a8fa8d3b6b15887da7a85400e4d2ed7cf34e8", ssa_ast = "3e3702a4fd62443fe6b090eb89f20ec7e27d324496d75b3ee42f3cda524291c2", flattened_ast = "fed29ad5348e4f3d7a8ba91547fdc14ec386c458c8260588054223091b21956d", destructured_ast = "ffe1d39bb59e15283aafed4676f6e1c9e01091aac0882e03d26f1f503b9123ad", inlined_ast = "ffe1d39bb59e15283aafed4676f6e1c9e01091aac0882e03d26f1f503b9123ad", dce_ast = "e759990e1e0be3d6e6a416664c8ba4035cd6bbf292a7987c9b8874ed07674826", bytecode = """ program test.aleo; struct foo: diff --git a/tests/expectations/compiler/signature/signature_with_wrong_types_fail.out b/tests/expectations/compiler/signature/signature_with_wrong_types_fail.out index 9afa684db7..faeac51441 100644 --- a/tests/expectations/compiler/signature/signature_with_wrong_types_fail.out +++ b/tests/expectations/compiler/signature/signature_with_wrong_types_fail.out @@ -1,32 +1,32 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372007]: Expected one type from `signature`, but got `address` +Error [ETYC0372117]: Expected type `signature` but type `address` was found. --> compiler-test:11:45 | 11 | let first: bool = signature::verify(a, s, v); | ^ -Error [ETYC0372007]: Expected one type from `address`, but got `signature` +Error [ETYC0372117]: Expected type `address` but type `signature` was found. --> compiler-test:11:48 | 11 | let first: bool = signature::verify(a, s, v); | ^ -Error [ETYC0372007]: Expected one type from `address`, but got `u8` +Error [ETYC0372117]: Expected type `address` but type `u8` was found. --> compiler-test:12:37 | 12 | let second: bool = s.verify(1u8, v); | ^^^ -Error [ETYC0372007]: Expected one type from `signature`, but got `address` +Error [ETYC0372117]: Expected type `signature` but type `address` was found. --> compiler-test:17:45 | 17 | let first: bool = signature::verify(a, v, s); | ^ -Error [ETYC0372007]: Expected one type from `address`, but got `foo` +Error [ETYC0372117]: Expected type `address` but type `foo` was found. --> compiler-test:17:48 | 17 | let first: bool = signature::verify(a, v, s); | ^ -Error [ETYC0372007]: Expected one type from `address`, but got `foo` +Error [ETYC0372117]: Expected type `address` but type `foo` was found. --> compiler-test:18:37 | 18 | let second: bool = s.verify(v, a); diff --git a/tests/expectations/compiler/statements/assign_ternary.out b/tests/expectations/compiler/statements/assign_ternary.out index 1beb8aec8b..349ea9a00b 100644 --- a/tests/expectations/compiler/statements/assign_ternary.out +++ b/tests/expectations/compiler/statements/assign_ternary.out @@ -1,11 +1,18 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `bool` but type `u32` was found +Error [ETYC0372117]: Expected type `bool` but type `u32` was found. --> compiler-test:5:30 | 5 | let x: bool = true ? x: true; | ^ +Error [ETYC0372118]: Received different types `u32` and `bool` for the arms of a ternary conditional. + --> compiler-test:5:23 + | + 5 | let x: bool = true ? x: true; + | ^^^^^^^^^^^^^^ + | + = Make both branches the same type. Error [EAST0372009]: variable `x` shadowed by --> compiler-test:5:13 | diff --git a/tests/expectations/compiler/statements/compare_diff_types_fail.out b/tests/expectations/compiler/statements/compare_diff_types_fail.out index e2f8403416..93f221a0ef 100644 --- a/tests/expectations/compiler/statements/compare_diff_types_fail.out +++ b/tests/expectations/compiler/statements/compare_diff_types_fail.out @@ -1,46 +1,55 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `u8` but type `i8` was found +Error [ETYC0372119]: Received different types `i8` and `u8` for the operation `==`. --> compiler-test:5:23 | 5 | let b: bool = a == 1u8; | ^^^^^^^^ -Error [ETYC0372003]: Expected type `u8` but type `i8` was found + | + = Make both operands the same type. +Error [ETYC0372119]: Received different types `i8` and `u8` for the operation `!=`. --> compiler-test:6:23 | 6 | let c: bool = a != 1u8; | ^^^^^^^^ -Error [ETYC0372003]: Expected type `u8` but type `i8` was found + | + = Make both operands the same type. +Error [ETYC0372119]: Received different types `i8` and `u8` for the operation `>`. --> compiler-test:7:23 | 7 | let d: bool = a > 1u8; | ^^^^^^^ -Error [ETYC0372003]: Expected type `u8` but type `i8` was found + | + = Make both operands the same type. +Error [ETYC0372119]: Received different types `i8` and `u8` for the operation `<`. --> compiler-test:8:23 | 8 | let e: bool = a < 1u8; | ^^^^^^^ -Error [ETYC0372003]: Expected type `u8` but type `i8` was found + | + = Make both operands the same type. +Error [ETYC0372119]: Received different types `i8` and `u8` for the operation `>=`. --> compiler-test:9:23 | 9 | let f: bool = a >= 1u8; | ^^^^^^^^ -Error [ETYC0372003]: Expected type `u8` but type `i8` was found + | + = Make both operands the same type. +Error [ETYC0372119]: Received different types `i8` and `u8` for the operation `<=`. --> compiler-test:10:23 | 10 | let g: bool = a <= 1u8; | ^^^^^^^^ -Error [ETYC0372003]: Expected type `i8` but type `u8` was found - --> compiler-test:11:26 | - 11 | let h: u32 = a * 1u8; - | ^^^ -Error [ETYC0372003]: Expected type `i8` but type `u32` was found + = Make both operands the same type. +Error [ETYC0372120]: Received types `i8` and `u8` for the operation `*`. --> compiler-test:11:22 | 11 | let h: u32 = a * 1u8; | ^^^^^^^ + | + = Valid operands are two integers of the same type, two fields, or a scalar and a group. Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/statements/compare_invalid_negates_fail.out b/tests/expectations/compiler/statements/compare_invalid_negates_fail.out index 6cf2387c7c..868ddec12b 100644 --- a/tests/expectations/compiler/statements/compare_invalid_negates_fail.out +++ b/tests/expectations/compiler/statements/compare_invalid_negates_fail.out @@ -1,71 +1,36 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372007]: Expected one type from `field, group, i8, i16, i32, i64, i128`, but got `u8` - --> compiler-test:5:24 - | - 5 | let b: bool = -a == -1u8; - | ^ Error [ETYC0372008]: The value -1 is not a valid `u8` --> compiler-test:5:29 | 5 | let b: bool = -a == -1u8; | ^^^^ -Error [ETYC0372007]: Expected one type from `field, group, i8, i16, i32, i64, i128`, but got `u8` - --> compiler-test:6:24 - | - 6 | let c: bool = -a > -1u8; - | ^ Error [ETYC0372008]: The value -1 is not a valid `u8` --> compiler-test:6:28 | 6 | let c: bool = -a > -1u8; | ^^^^ -Error [ETYC0372007]: Expected one type from `field, group, i8, i16, i32, i64, i128`, but got `u8` - --> compiler-test:7:24 - | - 7 | let d: bool = -a < -1u8; - | ^ Error [ETYC0372008]: The value -1 is not a valid `u8` --> compiler-test:7:28 | 7 | let d: bool = -a < -1u8; | ^^^^ -Error [ETYC0372007]: Expected one type from `field, group, i8, i16, i32, i64, i128`, but got `u8` - --> compiler-test:8:24 - | - 8 | let e: bool = -a >= -1u8; - | ^ Error [ETYC0372008]: The value -1 is not a valid `u8` --> compiler-test:8:29 | 8 | let e: bool = -a >= -1u8; | ^^^^ -Error [ETYC0372007]: Expected one type from `field, group, i8, i16, i32, i64, i128`, but got `u8` - --> compiler-test:9:24 - | - 9 | let f: bool = -a <= -1u8; - | ^ Error [ETYC0372008]: The value -1 is not a valid `u8` --> compiler-test:9:29 | 9 | let f: bool = -a <= -1u8; | ^^^^ -Error [ETYC0372007]: Expected one type from `field, group, i8, i16, i32, i64, i128`, but got `u8` - --> compiler-test:10:22 - | - 10 | let g: u8 = -a * -1u8; - | ^ Error [ETYC0372008]: The value -1 is not a valid `u8` --> compiler-test:10:26 | 10 | let g: u8 = -a * -1u8; | ^^^^ -Error [ETYC0372007]: Expected one type from `field, group, i8, i16, i32, i64, i128`, but got `u8` - --> compiler-test:11:22 - | - 11 | let h: u8 = -a ** -1u8; - | ^ Error [ETYC0372008]: The value -1 is not a valid `u8` --> compiler-test:11:27 | diff --git a/tests/expectations/compiler/statements/non_existant_vars_mul_fail.out b/tests/expectations/compiler/statements/non_existant_vars_mul_fail.out index 303529f5d8..f73fc26105 100644 --- a/tests/expectations/compiler/statements/non_existant_vars_mul_fail.out +++ b/tests/expectations/compiler/statements/non_existant_vars_mul_fail.out @@ -11,16 +11,6 @@ Error [ETYC0372005]: Unknown variable `z` | 5 | \tlet b: u8 = x*z; | ^ -Error [ETYC0372004]: Could not determine the type of `x` - --> compiler-test:5:18 - | - 5 | \tlet b: u8 = x*z; - | ^ -Error [ETYC0372004]: Could not determine the type of `z` - --> compiler-test:5:20 - | - 5 | \tlet b: u8 = x*z; - | ^ Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/statements/typecheck_statements_fail.out b/tests/expectations/compiler/statements/typecheck_statements_fail.out index a80d0d89f4..c7540b93b6 100644 --- a/tests/expectations/compiler/statements/typecheck_statements_fail.out +++ b/tests/expectations/compiler/statements/typecheck_statements_fail.out @@ -1,41 +1,30 @@ namespace = "Compile" expectation = "Fail" outputs = [''' -Error [ETYC0372003]: Expected type `i16` but type `i32` was found - --> compiler-test:5:33 - | - 5 | let c1 : u32 = 123i16 * 123i32; - | ^^^^^^ -Error [ETYC0372003]: Expected type `i16` but type `u32` was found +Error [ETYC0372120]: Received types `i16` and `i32` for the operation `*`. --> compiler-test:5:24 | 5 | let c1 : u32 = 123i16 * 123i32; | ^^^^^^^^^^^^^^^ + | + = Valid operands are two integers of the same type, two fields, or a scalar and a group. Error [ETYC0372045]: Strings are not yet supported. --> compiler-test:6:24 | 6 | let c2 : u32 = "123i32" * 123i16 * "sss"; | ^^^^^^^^ -Error [ETYC0372003]: Expected type `i16` but type `string` was found +Error [ETYC0372120]: Received types `string` and `i16` for the operation `*`. --> compiler-test:6:24 | 6 | let c2 : u32 = "123i32" * 123i16 * "sss"; - | ^^^^^^^^ -Error [ETYC0372045]: Strings are not yet supported. - --> compiler-test:6:44 + | ^^^^^^^^^^^^^^^^^ | - 6 | let c2 : u32 = "123i32" * 123i16 * "sss"; - | ^^^^^ -Error [ETYC0372003]: Expected type `i16` but type `string` was found + = Valid operands are two integers of the same type, two fields, or a scalar and a group. +Error [ETYC0372045]: Strings are not yet supported. --> compiler-test:6:44 | 6 | let c2 : u32 = "123i32" * 123i16 * "sss"; | ^^^^^ -Error [ETYC0372003]: Expected type `i16` but type `u32` was found - --> compiler-test:6:24 - | - 6 | let c2 : u32 = "123i32" * 123i16 * "sss"; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ Error [ETYC0372045]: Strings are not yet supported. --> compiler-test:7:24 | @@ -46,84 +35,52 @@ Error [ETYC0372045]: Strings are not yet supported. | 7 | let c3 : u32 = "123i32" * "sss"; | ^^^^^ -Error [ETYC0372003]: Expected type `field, group, integer, or scalar` but type `string` was found +Error [ETYC0372120]: Received types `string` and `string` for the operation `*`. --> compiler-test:7:24 | 7 | let c3 : u32 = "123i32" * "sss"; - | ^^^^^^^^ -Error [ETYC0372003]: Expected type `field, group, integer, or scalar` but type `string` was found - --> compiler-test:7:35 - | - 7 | let c3 : u32 = "123i32" * "sss"; - | ^^^^^ -Error [ETYC0372003]: Expected type `i8` but type `i16` was found - --> compiler-test:8:30 - | - 8 | let c4 : u32 = 1i8 * 2i16 * 3i32 * 4i64 * 5u8 * 6u16 * 7u32 * 9u64; - | ^^^^ -Error [ETYC0372003]: Expected type `i8` but type `i32` was found - --> compiler-test:8:37 - | - 8 | let c4 : u32 = 1i8 * 2i16 * 3i32 * 4i64 * 5u8 * 6u16 * 7u32 * 9u64; - | ^^^^ -Error [ETYC0372003]: Expected type `i8` but type `i64` was found - --> compiler-test:8:44 + | ^^^^^^^^^^^^^^^^ | - 8 | let c4 : u32 = 1i8 * 2i16 * 3i32 * 4i64 * 5u8 * 6u16 * 7u32 * 9u64; - | ^^^^ -Error [ETYC0372003]: Expected type `i8` but type `u8` was found - --> compiler-test:8:51 - | - 8 | let c4 : u32 = 1i8 * 2i16 * 3i32 * 4i64 * 5u8 * 6u16 * 7u32 * 9u64; - | ^^^ -Error [ETYC0372003]: Expected type `i8` but type `u16` was found - --> compiler-test:8:57 - | - 8 | let c4 : u32 = 1i8 * 2i16 * 3i32 * 4i64 * 5u8 * 6u16 * 7u32 * 9u64; - | ^^^^ -Error [ETYC0372003]: Expected type `i8` but type `u32` was found - --> compiler-test:8:64 - | - 8 | let c4 : u32 = 1i8 * 2i16 * 3i32 * 4i64 * 5u8 * 6u16 * 7u32 * 9u64; - | ^^^^ -Error [ETYC0372003]: Expected type `i8` but type `u64` was found - --> compiler-test:8:71 - | - 8 | let c4 : u32 = 1i8 * 2i16 * 3i32 * 4i64 * 5u8 * 6u16 * 7u32 * 9u64; - | ^^^^ -Error [ETYC0372003]: Expected type `i8` but type `u32` was found + = Valid operands are two integers of the same type, two fields, or a scalar and a group. +Error [ETYC0372120]: Received types `i8` and `i16` for the operation `*`. --> compiler-test:8:24 | 8 | let c4 : u32 = 1i8 * 2i16 * 3i32 * 4i64 * 5u8 * 6u16 * 7u32 * 9u64; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ + | + = Valid operands are two integers of the same type, two fields, or a scalar and a group. Error [ETYC0372045]: Strings are not yet supported. --> compiler-test:9:26 | 9 | let c16: bool = ("123i32" & 123i16) == ("sss" / 1i8 - 1i8 + 22u32); | ^^^^^^^^ -Error [ETYC0372003]: Expected type `i16` but type `string` was found +Error [ETYC0372117]: Expected a bool or integer but type `string` was found. + --> compiler-test:9:26 + | + 9 | let c16: bool = ("123i32" & 123i16) == ("sss" / 1i8 - 1i8 + 22u32); + | ^^^^^^^^ +Error [ETYC0372119]: Received different types `string` and `i16` for the operation `&`. --> compiler-test:9:26 | 9 | let c16: bool = ("123i32" & 123i16) == ("sss" / 1i8 - 1i8 + 22u32); | ^^^^^^^^^^^^^^^^^ + | + = Make both operands the same type. Error [ETYC0372045]: Strings are not yet supported. --> compiler-test:9:49 | 9 | let c16: bool = ("123i32" & 123i16) == ("sss" / 1i8 - 1i8 + 22u32); | ^^^^^ -Error [ETYC0372003]: Expected type `i8` but type `string` was found +Error [ETYC0372117]: Expected a field or integer but type `string` was found. --> compiler-test:9:49 | 9 | let c16: bool = ("123i32" & 123i16) == ("sss" / 1i8 - 1i8 + 22u32); - | ^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `i8` but type `string` was found + | ^^^^^ +Error [ETYC0372119]: Received different types `string` and `i8` for the operation `/`. --> compiler-test:9:49 | 9 | let c16: bool = ("123i32" & 123i16) == ("sss" / 1i8 - 1i8 + 22u32); - | ^^^^^^^^^^^^^^^^^ -Error [ETYC0372003]: Expected type `u32` but type `string` was found - --> compiler-test:9:49 + | ^^^^^^^^^^^ | - 9 | let c16: bool = ("123i32" & 123i16) == ("sss" / 1i8 - 1i8 + 22u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + = Make both operands the same type. '''] diff --git a/tests/expectations/compiler/statements/unknown_type_in_definition_fail.out b/tests/expectations/compiler/statements/unknown_type_in_definition_fail.out index 33d0853344..166788f42e 100644 --- a/tests/expectations/compiler/statements/unknown_type_in_definition_fail.out +++ b/tests/expectations/compiler/statements/unknown_type_in_definition_fail.out @@ -8,7 +8,7 @@ Error [ETYC0372017]: The type `Foo` is not found in the current scope. | ^^^^^^^^^^^^^^^^ | = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits` -Error [ETYC0372003]: Expected type `Foo` but type `u8` was found +Error [ETYC0372117]: Expected type `Foo` but type `u8` was found. --> compiler-test:5:19 | 5 | \tlet b: Foo = 1u8; diff --git a/tests/expectations/compiler/structs/external_record.out b/tests/expectations/compiler/structs/external_record.out index 2f823b603b..230b7b2992 100644 --- a/tests/expectations/compiler/structs/external_record.out +++ b/tests/expectations/compiler/structs/external_record.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "340c54b67bf4ed5c52a8c178e9cd7f7f8aa1d733cc157327b14cd9658b386ae6", type_checked_symbol_table = "d972634f150980436170caf1f7ebaa08f35f59f0c68166ca2df8a9ebdf4c71e5", unrolled_symbol_table = "d972634f150980436170caf1f7ebaa08f35f59f0c68166ca2df8a9ebdf4c71e5", initial_ast = "d4a02a93f27d962ced13da70e6e78fb8b53c585fab7232c4afb6ebdb97751880", unrolled_ast = "d4a02a93f27d962ced13da70e6e78fb8b53c585fab7232c4afb6ebdb97751880", ssa_ast = "196758b126b3b83c899c1d7bfccc7caf76b275f5ea5797da6d7b62f9d46d13cb", flattened_ast = "51b1fc2019f67cf0624405a13151677297b6b87207d41bde6e45edd221163898", destructured_ast = "ea1edb23d0539d5c6af1d224d82f00494a4809b5a59a3fe6ef7d151639f590c8", inlined_ast = "ea1edb23d0539d5c6af1d224d82f00494a4809b5a59a3fe6ef7d151639f590c8", dce_ast = "ea1edb23d0539d5c6af1d224d82f00494a4809b5a59a3fe6ef7d151639f590c8", bytecode = """ + { initial_symbol_table = "50662e3d64bb2aac7c70938b0b76cf86d9d8a9b71533dab9077a08aa3b659388", type_checked_symbol_table = "cd57bf4d1a4ffa671fc0d2712e65802b5273f9c879fa461e7b75ee11e839b50e", unrolled_symbol_table = "cd57bf4d1a4ffa671fc0d2712e65802b5273f9c879fa461e7b75ee11e839b50e", initial_ast = "688dba570636a29b20e0f00772838dd74a74e2b4378bf47a7c026434bbf19aa7", unrolled_ast = "688dba570636a29b20e0f00772838dd74a74e2b4378bf47a7c026434bbf19aa7", ssa_ast = "fcd251f93a48549b72a309b7dd3cbbae319a478d48870df59ad08b8c3b7131f0", flattened_ast = "7d105ab28317fe2a5e2b3a36dbabc6e846fa6e9abfa98c4c439dbd4ad6db983e", destructured_ast = "61db2d518332ff256df01615050d9073e3ecfcaa51ce77cac5bbae65c88a292e", inlined_ast = "61db2d518332ff256df01615050d9073e3ecfcaa51ce77cac5bbae65c88a292e", dce_ast = "61db2d518332ff256df01615050d9073e3ecfcaa51ce77cac5bbae65c88a292e", bytecode = """ program child.aleo; record A: @@ -14,7 +14,7 @@ function mint: cast r0 r1 into r2 as A.record; output r2 as A.record; """, errors = "", warnings = "" }, - { initial_symbol_table = "3e72c903f6f9ab2438076da7c329b8cd369c9c3307d14bff4963e8a8f6bb18e0", type_checked_symbol_table = "27f40a9e28a4b7d03d5c91be8a1893b766ac0e9be2d8a7c5ababe68b45ee01c7", unrolled_symbol_table = "27f40a9e28a4b7d03d5c91be8a1893b766ac0e9be2d8a7c5ababe68b45ee01c7", initial_ast = "bf17af18b2264841e5933766b4bd190c7139d59d121e1c2a1b7a0c37715f90b2", unrolled_ast = "c82dddfcac1fec8f63b8dfce008fd6cb000b7f603fd22611ae000adefcb4246c", ssa_ast = "97069a75c94ed52904c922470f78a75abcab70ec1a7f5966febe8cae605efb8e", flattened_ast = "be815a3a27a747ffd6f1c6d87dccba6f90c6d90e3b78fd50112f77f5289fb5eb", destructured_ast = "b29a50cae659e63902e0137059becdf6f15d00c7aeded8f68ef97a95e9de2fbc", inlined_ast = "b29a50cae659e63902e0137059becdf6f15d00c7aeded8f68ef97a95e9de2fbc", dce_ast = "b29a50cae659e63902e0137059becdf6f15d00c7aeded8f68ef97a95e9de2fbc", bytecode = """ + { initial_symbol_table = "0f6afe05e956eae011e68a9f6e66b0734caef808354fb213909d7535be9bef6b", type_checked_symbol_table = "20baa69c206e4cfdb6dea6ad458a820d0bd17afafc6deafc54d9f31a6b8a1b7b", unrolled_symbol_table = "20baa69c206e4cfdb6dea6ad458a820d0bd17afafc6deafc54d9f31a6b8a1b7b", initial_ast = "9f94e48836537273a76806128487075f8cd83f8d14a0543d109f83f9f979d063", unrolled_ast = "5a2107c306f81799bde7a3c477f13a117c247497f9b464be28514922ebc14d8f", ssa_ast = "df723b9e8a19479d26502a7ddd034485564e7511948326472a3d89540543f2e4", flattened_ast = "fdd248667a657e1e98e9bfbecbf2078545fee565b9d490e2a9bbaa28487168b5", destructured_ast = "c8a1ddfb9f38141573719c68507b09e54900971896f595188abc0b3e76e6da5c", inlined_ast = "c8a1ddfb9f38141573719c68507b09e54900971896f595188abc0b3e76e6da5c", dce_ast = "c8a1ddfb9f38141573719c68507b09e54900971896f595188abc0b3e76e6da5c", bytecode = """ import child.aleo; program parent.aleo; @@ -30,7 +30,7 @@ function wrapper_mint: output r2 as child.aleo/A.record; output r3 as B.record; """, errors = "", warnings = "" }, - { initial_symbol_table = "78c72f7c5e19d1f0fbd6073ed85b5f7977f912d671e4c522bd27652647b19733", type_checked_symbol_table = "6c8f504dd11151208a41f10109046e49a18fb4609706a71c01a11eb5d16128bb", unrolled_symbol_table = "6c8f504dd11151208a41f10109046e49a18fb4609706a71c01a11eb5d16128bb", initial_ast = "65349655f9b288bcb18caaa1d1216e7678f0e3919b740719d1a9f9660124f7ec", unrolled_ast = "6ad3178891c74b6042bddee324c5dce52addcf62565d3457154b907863926f9a", ssa_ast = "6af16bac66f4da284d7bb27542f90f77a4eb6ffcc7915aa1ea64953a899437e9", flattened_ast = "afb3257ab605fb3ba64f07f5400edce3206ea852d567f5e16962c9e6b0b3c47b", destructured_ast = "819770e49c3158317e2a112c99aed86f6cc14b4c61eda5acbf796973fcdeedc7", inlined_ast = "819770e49c3158317e2a112c99aed86f6cc14b4c61eda5acbf796973fcdeedc7", dce_ast = "819770e49c3158317e2a112c99aed86f6cc14b4c61eda5acbf796973fcdeedc7", bytecode = """ + { initial_symbol_table = "92cf9d88141f1b4a7bc5b2eb903415d2ba1e8c9e8d8dda20fc7242bfdf7dab04", type_checked_symbol_table = "c2af26753168c8b97c141ec129baef50011baa8056d508e34977cf85e4f3fea4", unrolled_symbol_table = "c2af26753168c8b97c141ec129baef50011baa8056d508e34977cf85e4f3fea4", initial_ast = "804bc7f48060b4981c6440c819b3a08d80295f775f7db22b7d58542817d90663", unrolled_ast = "6f1e27481eacbbc36f54ac0ec51bfd0372382ba8512b3f2ed00d411bda9e046f", ssa_ast = "afe0808023b6a1328cd6174f475ca97a5f143e84fa473330d1357c5da8531989", flattened_ast = "abbebfebc939daf4ae0dab816b699840e84299f664de1fdf270f84285f5fb69b", destructured_ast = "2c8e8bdb7822ce79f46ab525efd45ee0e6748c5ff8254226fdbb45baa6e2477e", inlined_ast = "2c8e8bdb7822ce79f46ab525efd45ee0e6748c5ff8254226fdbb45baa6e2477e", dce_ast = "2c8e8bdb7822ce79f46ab525efd45ee0e6748c5ff8254226fdbb45baa6e2477e", bytecode = """ import child.aleo; import parent.aleo; program grandparent.aleo; diff --git a/tests/expectations/compiler/structs/external_struct.out b/tests/expectations/compiler/structs/external_struct.out index c07a04dc0b..91cfa0a9b6 100644 --- a/tests/expectations/compiler/structs/external_struct.out +++ b/tests/expectations/compiler/structs/external_struct.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "b9d02d1b85ab19ec91480212bbfe3b765bc663861026aa9dbb97b31ec1e4996b", type_checked_symbol_table = "135897b1dbcb1676d36ac8d1aa865381e9530287bb7449442ea446c29bb6449c", unrolled_symbol_table = "135897b1dbcb1676d36ac8d1aa865381e9530287bb7449442ea446c29bb6449c", initial_ast = "067591039f4d58fae5acf7c987d08fead46a25d06278ec74b3d0e41851a1f2e3", unrolled_ast = "067591039f4d58fae5acf7c987d08fead46a25d06278ec74b3d0e41851a1f2e3", ssa_ast = "af24b1aeb7c1a05116ed5c1a718067de95c2365a0532e9d97bd1cf69912a70fa", flattened_ast = "c3d8cff7286b7d1187046982da77a9527f2753d62e914407cb5d42b4242636fd", destructured_ast = "3d04c9faddeaf8bc7839934ecc75b0dfe973c198e0c19bf0683a16ba3f13cdef", inlined_ast = "3d04c9faddeaf8bc7839934ecc75b0dfe973c198e0c19bf0683a16ba3f13cdef", dce_ast = "3d04c9faddeaf8bc7839934ecc75b0dfe973c198e0c19bf0683a16ba3f13cdef", bytecode = """ + { initial_symbol_table = "fc55b69f12696a6aa4db23fdc6df7c02cde6867224f86ad9ac9e11c218f8f679", type_checked_symbol_table = "fb0bc380e6df683fad13007c50a0d3d79529ca5da9e1b342893d799ccb79dcfb", unrolled_symbol_table = "fb0bc380e6df683fad13007c50a0d3d79529ca5da9e1b342893d799ccb79dcfb", initial_ast = "80d537920cacd874248c4a04ad1c7f13fd9150a77c5f358786816ed23f7f1469", unrolled_ast = "80d537920cacd874248c4a04ad1c7f13fd9150a77c5f358786816ed23f7f1469", ssa_ast = "67b51b20c2e292a780020ab8605917f45108cf5348bf7221230224785a2ff9f5", flattened_ast = "0fcd3068648256a2f8f2d6ecbf015bb4be6e6ca3934361d9c7dff005db969b42", destructured_ast = "358a6f584cd0f6cb72940bed001c4f899ab5bec64fd853ecd77bbde396554329", inlined_ast = "358a6f584cd0f6cb72940bed001c4f899ab5bec64fd853ecd77bbde396554329", dce_ast = "358a6f584cd0f6cb72940bed001c4f899ab5bec64fd853ecd77bbde396554329", bytecode = """ program child.aleo; struct Two: @@ -43,7 +43,7 @@ function create: output r13 as Foo.private; output r14 as Boo.record; """, errors = "", warnings = "" }, - { initial_symbol_table = "f2ae8eee41238514bb792b1b782feab70aa865807bb489187726796a3d5198b7", type_checked_symbol_table = "f7765fa8c7a391f3250f9c2ff124729fe8592f32dbc82d7e9428682df49ea351", unrolled_symbol_table = "f7765fa8c7a391f3250f9c2ff124729fe8592f32dbc82d7e9428682df49ea351", initial_ast = "90f2be69e327a67e772bab6e517a1efe90d6fbbdcda2ab69e73c48dd5ea413cd", unrolled_ast = "163290d0f28722f746b4d4541abe84c17a91c65a8c7d690b98b7f0af19994ad5", ssa_ast = "a112118a15f292e6c7f1c19cea3d817142e53f4eeb9519991d451d2544473fd7", flattened_ast = "42734a56fa5e1bcd21832d5c83e314cbc249b5d8437ebbc072052a07fbb22070", destructured_ast = "56c2bd2789e46f95b9e93b225777b4a6178cbedd75256c4adf21df9f65485ea5", inlined_ast = "56c2bd2789e46f95b9e93b225777b4a6178cbedd75256c4adf21df9f65485ea5", dce_ast = "26bd4e6f56705dd313f4fa58b964be29576620e0b6a2fc25d9ad55bd89a88413", bytecode = """ + { initial_symbol_table = "6a1401592c3ad0a638161a8357ad2936ded8b5d3928465c4566fffffd94849a3", type_checked_symbol_table = "047260233842e38e392ef647bfb8d716e9121162eb06c97b923470966d8044a4", unrolled_symbol_table = "047260233842e38e392ef647bfb8d716e9121162eb06c97b923470966d8044a4", initial_ast = "6f336cf5b1dafd7cada6e05cf192fc1ea445eb7e0e4c363e61a814fae25b7461", unrolled_ast = "7d0e93818e46dc27ec5cd5c79d71f2ed3f88ec714075ddd364894a452bd73635", ssa_ast = "e1d7cf6ccc11755eed857785d7e09ff4f4daa21b6cc860bd8ac8449c270048f9", flattened_ast = "977ed6c81080f5dac68137e97d69b48e3476db3fc2770d0dd8fbb85db6801c4c", destructured_ast = "f6a21b79481faf95ff0495d9579510ff82e0f87fbf7c28f05b42e5921478eff8", inlined_ast = "f6a21b79481faf95ff0495d9579510ff82e0f87fbf7c28f05b42e5921478eff8", dce_ast = "ad6e474e1263201bdec885ca22305ce4965fbe7e3b27d7e7c6d3e12b5b89150b", bytecode = """ import child.aleo; program parent.aleo; @@ -87,7 +87,7 @@ function create_another_wrapper: output r3 as BooHoo.record; output r4 as Woo.private; """, errors = "", warnings = "" }, - { initial_symbol_table = "de21200cc8a95064b4a4b2d7a1f194d3b54595212e607ee49edd716cbf6dd17e", type_checked_symbol_table = "4e42579ae5f24adba68080229fc51fd767334ad987d82c6f755fe90d20b4cd29", unrolled_symbol_table = "4e42579ae5f24adba68080229fc51fd767334ad987d82c6f755fe90d20b4cd29", initial_ast = "0cc09a6fcaafb39da24c46d650f915c6352b593958d991f45b0ec61ef3bf01bb", unrolled_ast = "3f95452c2a8d57484c7814740d596de17d20bf04d812e7b106ca1eb1273be3cd", ssa_ast = "1b9583fe511e9f5705f2cd4d0566d697929b8c2480709f9c14378658e64a67f5", flattened_ast = "c4c6d893a4252bdd83ff40b1109057545c57474e4636188b22dd7f936a14e42c", destructured_ast = "b4c4946001c3c5eeb47744a365a7908728a8de9b8d8a8cf0fe3d4072870168e3", inlined_ast = "b4c4946001c3c5eeb47744a365a7908728a8de9b8d8a8cf0fe3d4072870168e3", dce_ast = "b3ae1144d78b74320dde8741d8b779408a633b5a152efce15f6c9f38abe957ad", bytecode = """ + { initial_symbol_table = "b306d346cd841f7bc6e031c0ff4851c927653dc56b5b3adb13aaadbe89489049", type_checked_symbol_table = "1142d55f9b6d152821d90ff290e4281eab525d958d94eca5ec43f530f2cbc103", unrolled_symbol_table = "1142d55f9b6d152821d90ff290e4281eab525d958d94eca5ec43f530f2cbc103", initial_ast = "8473d0584e78127a612fccd0c20273d13283bb10bf900bf0fe68963b04ff9d0e", unrolled_ast = "7cb18813e965a7a08a18d597d6a23958ff79173f933727a94a24a9385ee56376", ssa_ast = "0baea5ed9699697f273a46fe1e7f404c1d1542f185d2dda64d6523839e2d46fd", flattened_ast = "680d358399608944e8d5a8e19aeacf3b9971c4fb5df0d1719cd047c7f3dc894f", destructured_ast = "0d40e06ad7f875d3f7883bbf3b774c3929acb1e016db4b7053c84da435c46b8e", inlined_ast = "0d40e06ad7f875d3f7883bbf3b774c3929acb1e016db4b7053c84da435c46b8e", dce_ast = "b7ca078dbbabed304e97d337aab582faad12d6d8a82ea998d8d347bc2d43b01b", bytecode = """ import child.aleo; import parent.aleo; program grandparent.aleo; diff --git a/tests/expectations/compiler/structs/external_struct_in_async_function.out b/tests/expectations/compiler/structs/external_struct_in_async_function.out index b225b5672a..68cf366228 100644 --- a/tests/expectations/compiler/structs/external_struct_in_async_function.out +++ b/tests/expectations/compiler/structs/external_struct_in_async_function.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "52de8e39e7909bf371547bcd54ab3e76fd09cbd6544a5772d042c4d25c996e2c", type_checked_symbol_table = "b15217927f45cc35af145e9c260af0d8ac353f397a29ca444ff4a95258610db8", unrolled_symbol_table = "b15217927f45cc35af145e9c260af0d8ac353f397a29ca444ff4a95258610db8", initial_ast = "b4c949f6c13875d2cfdc35c1cfeeb6eee60eaa02b40736f21f7299643f554bf6", unrolled_ast = "b4c949f6c13875d2cfdc35c1cfeeb6eee60eaa02b40736f21f7299643f554bf6", ssa_ast = "ba1b08fbe9a242a88e6c13d8be7691a1fb2e9bf45abd6c089ea0f4659ec38866", flattened_ast = "e8a54be927eb0d70f57e05142476382f2c3ef64b9d0a52a3e95b2bad0ba46764", destructured_ast = "073fe0dab04571576a62611e9781356da18c58cbf08d910ab61d2179f249bc5d", inlined_ast = "7d4857f2b1507ba362be0e6a1aa273a2c849cb6080fbfb4a9759232ba7701d0a", dce_ast = "7d4857f2b1507ba362be0e6a1aa273a2c849cb6080fbfb4a9759232ba7701d0a", bytecode = """ + { initial_symbol_table = "beae091e9fb22095a2f535f5bc313b94ba28e7fb7c4a91b0fe46594904681235", type_checked_symbol_table = "30442d4cb92da1e328eac3fb3d8b80e023f0e13b68ee5c5ea38c53921e7d1316", unrolled_symbol_table = "30442d4cb92da1e328eac3fb3d8b80e023f0e13b68ee5c5ea38c53921e7d1316", initial_ast = "dfb2a5dca7b21b4eb06219c8f616cc693862287c2b97f24a23736c56b105db5a", unrolled_ast = "dfb2a5dca7b21b4eb06219c8f616cc693862287c2b97f24a23736c56b105db5a", ssa_ast = "caac3c70ecf19722963866758522241698f40ab7749c8ff62f829387fb331fba", flattened_ast = "f20625031bf75a66d4be965847b9c38b94e51f6d5a63d4a84190e398863ea093", destructured_ast = "649e13977b743f61997f9163a8b580c794affb374dabe26bb5fc6d0b69fe255e", inlined_ast = "9ce711fdf38df420e2988871d7b4ef30540dc188a0e5b2aa7b7d0bbebf882c6b", dce_ast = "9ce711fdf38df420e2988871d7b4ef30540dc188a0e5b2aa7b7d0bbebf882c6b", bytecode = """ program parent.aleo; struct TestStruct: diff --git a/tests/expectations/compiler/structs/inline.out b/tests/expectations/compiler/structs/inline.out index f64766388a..1e91e6c14f 100644 --- a/tests/expectations/compiler/structs/inline.out +++ b/tests/expectations/compiler/structs/inline.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "c26f65afb3f8c6a068dd98b49503e30e69d0ce68c50727723a78e0bd77ce7095", type_checked_symbol_table = "3ea359eb04e150a68c8d9f940330ce63d689114d2bb47211dffcfd7370a6b1ba", unrolled_symbol_table = "3ea359eb04e150a68c8d9f940330ce63d689114d2bb47211dffcfd7370a6b1ba", initial_ast = "8240026b64541e67f9c2d69f59793310262c3b570caed19025a988551526e389", unrolled_ast = "8240026b64541e67f9c2d69f59793310262c3b570caed19025a988551526e389", ssa_ast = "af27b467011e346f5e23d55919c971abbdee3d977fa6f66f1f2874edd69838c5", flattened_ast = "97edd75c3be5d9423ec75cc43195724f29a4f391e275b21aa6005102364eca46", destructured_ast = "6da69e57d85dca6aeb6d2667e1528e86483ac9868f1ccb4a5b4a886893be5abf", inlined_ast = "6da69e57d85dca6aeb6d2667e1528e86483ac9868f1ccb4a5b4a886893be5abf", dce_ast = "6da69e57d85dca6aeb6d2667e1528e86483ac9868f1ccb4a5b4a886893be5abf", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "c26f65afb3f8c6a068dd98b49503e30e69d0ce68c50727723a78e0bd77ce7095", type_checked_symbol_table = "af1aa96bc2e6d4df25843659f939f795ea61ecbdfe2de7fe42e53899ad3bfc47", unrolled_symbol_table = "af1aa96bc2e6d4df25843659f939f795ea61ecbdfe2de7fe42e53899ad3bfc47", initial_ast = "720997e02c7f2ce03685fe398e736292110f425d30c17abebc269cb395cd8dfc", unrolled_ast = "720997e02c7f2ce03685fe398e736292110f425d30c17abebc269cb395cd8dfc", ssa_ast = "af27b467011e346f5e23d55919c971abbdee3d977fa6f66f1f2874edd69838c5", flattened_ast = "97edd75c3be5d9423ec75cc43195724f29a4f391e275b21aa6005102364eca46", destructured_ast = "6da69e57d85dca6aeb6d2667e1528e86483ac9868f1ccb4a5b4a886893be5abf", inlined_ast = "6da69e57d85dca6aeb6d2667e1528e86483ac9868f1ccb4a5b4a886893be5abf", dce_ast = "6da69e57d85dca6aeb6d2667e1528e86483ac9868f1ccb4a5b4a886893be5abf", bytecode = """ program test.aleo; struct Foo: diff --git a/tests/expectations/compiler/structs/inline_undefined.out b/tests/expectations/compiler/structs/inline_undefined.out index 01bc568a46..c9db2263ef 100644 --- a/tests/expectations/compiler/structs/inline_undefined.out +++ b/tests/expectations/compiler/structs/inline_undefined.out @@ -8,7 +8,7 @@ Error [ETYC0372017]: The type `Foo` is not found in the current scope. | ^^^^^^^^^^^^^^^^^^^^ | = If you are using an external type, make sure to preface with the program name. Ex: `credits.aleo/credits` instead of `credits` -Error [ETYC0372005]: Unknown struct `Foo` +Error [ETYC0372005]: Unknown struct or record `Foo` --> compiler-test:5:22 | 5 | let a: Foo = Foo { }; diff --git a/tests/expectations/compiler/structs/member_variable.out b/tests/expectations/compiler/structs/member_variable.out index 99e5b63ed2..c10cadf7bc 100644 --- a/tests/expectations/compiler/structs/member_variable.out +++ b/tests/expectations/compiler/structs/member_variable.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "96982aa1a232b95f3cce88dc995284e778631b168af89eb4f049f360cf5c2009", type_checked_symbol_table = "5bc0f2db28ffc8161fe3be96fe3af4fc1b8d5a518c1ea8389f035b4e93aa30b6", unrolled_symbol_table = "5bc0f2db28ffc8161fe3be96fe3af4fc1b8d5a518c1ea8389f035b4e93aa30b6", initial_ast = "6da87355d5a0e9536d0696f385d66382858d2c36a8ed24ebec49d95beac55980", unrolled_ast = "6da87355d5a0e9536d0696f385d66382858d2c36a8ed24ebec49d95beac55980", ssa_ast = "cf645e1be13a0e77fe51422b2577805ec94ef0d975301860f0a950ca291dbea4", flattened_ast = "8845d50db3bfe49287e668ae154fa034204bfa55269013cc73733398e1022b1a", destructured_ast = "a7f28cc5f9919c72ef312cdfe442d985a2f1e1ac488d4e1a1f9ed212d0e9ffff", inlined_ast = "a7f28cc5f9919c72ef312cdfe442d985a2f1e1ac488d4e1a1f9ed212d0e9ffff", dce_ast = "a7f28cc5f9919c72ef312cdfe442d985a2f1e1ac488d4e1a1f9ed212d0e9ffff", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "96982aa1a232b95f3cce88dc995284e778631b168af89eb4f049f360cf5c2009", type_checked_symbol_table = "ab873c25ac932e42a11406c40b0458bdf26e596cf654ee642582853784aae19f", unrolled_symbol_table = "ab873c25ac932e42a11406c40b0458bdf26e596cf654ee642582853784aae19f", initial_ast = "d89b9fdb5e70b86d396086607556d2948e8d9c6c5f5ef5bac79f5693f998e0ce", unrolled_ast = "d89b9fdb5e70b86d396086607556d2948e8d9c6c5f5ef5bac79f5693f998e0ce", ssa_ast = "cf645e1be13a0e77fe51422b2577805ec94ef0d975301860f0a950ca291dbea4", flattened_ast = "8845d50db3bfe49287e668ae154fa034204bfa55269013cc73733398e1022b1a", destructured_ast = "a7f28cc5f9919c72ef312cdfe442d985a2f1e1ac488d4e1a1f9ed212d0e9ffff", inlined_ast = "a7f28cc5f9919c72ef312cdfe442d985a2f1e1ac488d4e1a1f9ed212d0e9ffff", dce_ast = "a7f28cc5f9919c72ef312cdfe442d985a2f1e1ac488d4e1a1f9ed212d0e9ffff", bytecode = """ program test.aleo; struct Foo: diff --git a/tests/expectations/compiler/structs/redefine_external_struct.out b/tests/expectations/compiler/structs/redefine_external_struct.out index 8aeec34cc8..0aa169e001 100644 --- a/tests/expectations/compiler/structs/redefine_external_struct.out +++ b/tests/expectations/compiler/structs/redefine_external_struct.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Pass" outputs = [[{ compile = [ - { initial_symbol_table = "74e53781a60f54132c609b3b03492c4250036c379e5204b93329a9f57d49fe91", type_checked_symbol_table = "8851bc9f35e154359b0cbcc34f19cd64e3ebfcbacd301e070ad4b44e399d897c", unrolled_symbol_table = "8851bc9f35e154359b0cbcc34f19cd64e3ebfcbacd301e070ad4b44e399d897c", initial_ast = "74b39a65214c6dd05311092d4e59bd51eae97ebd18d1d680b1db55cfb54beddf", unrolled_ast = "74b39a65214c6dd05311092d4e59bd51eae97ebd18d1d680b1db55cfb54beddf", ssa_ast = "9d457405594c43b13f129dcd8b95302086654fa55355b387c83aabaaee1f2d6d", flattened_ast = "03e9facafccbbc398b682d08a79df26fdd778b91f2f4bed225ce5a5323e2171b", destructured_ast = "1970939a0425fa00978dc2822b28f011d3c27a16aa6d9e4bad7ff681a0a7411f", inlined_ast = "1970939a0425fa00978dc2822b28f011d3c27a16aa6d9e4bad7ff681a0a7411f", dce_ast = "1970939a0425fa00978dc2822b28f011d3c27a16aa6d9e4bad7ff681a0a7411f", bytecode = """ + { initial_symbol_table = "ff8f37ca6c53b7b4677f08131cf436699da021db3dd005850165903ed7803ab5", type_checked_symbol_table = "f962ac1942b6d25f4ca2fa398dd1067c44e56ace190aa36987ac9bc5614d4965", unrolled_symbol_table = "f962ac1942b6d25f4ca2fa398dd1067c44e56ace190aa36987ac9bc5614d4965", initial_ast = "1099e85d3866b5e46c17fbd0defc0e9276bd79a2a806abcf03a05d329fd235b8", unrolled_ast = "1099e85d3866b5e46c17fbd0defc0e9276bd79a2a806abcf03a05d329fd235b8", ssa_ast = "7ff9fbb26944ad717bd0f494d8b482fb0d3bf2cda4c4a10f1ba65daafe4321bf", flattened_ast = "bba9c79be8821a9bb7f5bc2f29b338b9845269a1469167c7cc2691489f58d850", destructured_ast = "b73b2c5fef99ba7d205693d1f80133273e4656bb81c754b2e656386421e82c5a", inlined_ast = "b73b2c5fef99ba7d205693d1f80133273e4656bb81c754b2e656386421e82c5a", dce_ast = "b73b2c5fef99ba7d205693d1f80133273e4656bb81c754b2e656386421e82c5a", bytecode = """ program child.aleo; struct Two: @@ -37,7 +37,7 @@ function create: cast r12 into r13 as Foo; output r13 as Foo.private; """, errors = "", warnings = "" }, - { initial_symbol_table = "bb3a69180106d91616ac9d6778fe8aee0fbdaab72b1b079183ebd0fcf772e359", type_checked_symbol_table = "92c4575a892476360e9efc1a118f534c1901622faca71626bb5778f76332e5cb", unrolled_symbol_table = "92c4575a892476360e9efc1a118f534c1901622faca71626bb5778f76332e5cb", initial_ast = "4406bc30d232c90c5069c388652b051dbb9e5378a20f38e69cf9f847ae83aee0", unrolled_ast = "2f3e72af631b9e4cdd067c40959e112bb0a7d1a5076a6c44b818c322ab4229f7", ssa_ast = "fcc3c8e717138f0c75a3c7765b26af7e5d009d1d7afd239b782ef56f0b0f3763", flattened_ast = "435f235eed4f63f31e391e6455014bd64de1320f147d156e4453414dca21752f", destructured_ast = "cdce20251477a5fa781fb90ae69dd08e12710b9d39363d4eecbfb81ac05e7481", inlined_ast = "cdce20251477a5fa781fb90ae69dd08e12710b9d39363d4eecbfb81ac05e7481", dce_ast = "a40a9b93296c22a41a527727f8cf61dc11dbed23ac00c3577333a63d6d1393f8", bytecode = """ + { initial_symbol_table = "3610688299402f88e6db90dbeb8e817a9abf90a05a7b8cc36a5224dd66d16348", type_checked_symbol_table = "a47cec23baa349ff7a80a53a7f1726e1e3b29724779c877d689fcfb81624632a", unrolled_symbol_table = "a47cec23baa349ff7a80a53a7f1726e1e3b29724779c877d689fcfb81624632a", initial_ast = "c52ee7318f9217bbdaf84d1c1567ba00a7dbcc7171ab0884f318c5a8cf58382d", unrolled_ast = "6de6d6b771640a0558fa2a002317f88367cca98452bc06647fd3d6279f7ae527", ssa_ast = "68deede0d9a4bf893092fb18708e5edb0acef701896b2b216ca980a53031a381", flattened_ast = "135d4523a25c0c8f456f18ab7482b6625ef30463aa1d288dac5bc07b1e4995b1", destructured_ast = "0510356bf186e38cb818ca083b57b1330ff19fda54dd5818f3b45936065e06cd", inlined_ast = "0510356bf186e38cb818ca083b57b1330ff19fda54dd5818f3b45936065e06cd", dce_ast = "fa5b26471547574040dc8597e9512836d793d44e63db0db99a00bbd41bf06193", bytecode = """ import child.aleo; program parent.aleo; diff --git a/tests/expectations/compiler/structs/struct_access_fail.out b/tests/expectations/compiler/structs/struct_access_fail.out index ffa1658d1f..4f84e3c134 100644 --- a/tests/expectations/compiler/structs/struct_access_fail.out +++ b/tests/expectations/compiler/structs/struct_access_fail.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `i8` but type `u32` was found +Error [ETYC0372117]: Expected type `i8` but type `u32` was found. --> compiler-test:11:21 | 11 | let x: i8 = s.f1; diff --git a/tests/expectations/compiler/structs/struct_declaration_out_of_order.out b/tests/expectations/compiler/structs/struct_declaration_out_of_order.out index 77ad80f41d..3c9a2d56b7 100644 --- a/tests/expectations/compiler/structs/struct_declaration_out_of_order.out +++ b/tests/expectations/compiler/structs/struct_declaration_out_of_order.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "be950b64dff74bb4ad08faa37527874d28cc07461aa058f03d4d5e8994984d51", type_checked_symbol_table = "b3a46c44d3dce231e93a790aaf2ca0a2428a35e7180603c314191673e969a871", unrolled_symbol_table = "b3a46c44d3dce231e93a790aaf2ca0a2428a35e7180603c314191673e969a871", initial_ast = "6f30585164eb4d8aff31f8427cb667740fde41ed391820f1536201b027933020", unrolled_ast = "6f30585164eb4d8aff31f8427cb667740fde41ed391820f1536201b027933020", ssa_ast = "753d548ee07f7271eea880232061fa6cf6fbe0cf33305adf27b99e77084a4d75", flattened_ast = "155b30d8457f01a785c924db88f2e56cb8eed24f0b4734162002e6c8c5641b84", destructured_ast = "81a07e90a02d1819b7a507066af8c4890a435bc44f29a76082eae87567518ad6", inlined_ast = "81a07e90a02d1819b7a507066af8c4890a435bc44f29a76082eae87567518ad6", dce_ast = "81a07e90a02d1819b7a507066af8c4890a435bc44f29a76082eae87567518ad6", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "a3d1a114d549f3015e21e7909e8901e9dc29f5f410004a9a2be326a03d5eabe3", type_checked_symbol_table = "bbf5ff1971dbb3db822ea2f6bc6e8f54d2e4b8e4442e91f473433586642e1363", unrolled_symbol_table = "bbf5ff1971dbb3db822ea2f6bc6e8f54d2e4b8e4442e91f473433586642e1363", initial_ast = "53b8b645d4d7ff0927780fc8018008808d36b4442113476652e70f6c266e8cda", unrolled_ast = "53b8b645d4d7ff0927780fc8018008808d36b4442113476652e70f6c266e8cda", ssa_ast = "db5ce2216227d15eb0952bd5dfde4f3e50da0f2e21e3949d949e61f8ee4d8811", flattened_ast = "fc9049e078b4fa078189d9b11080df584bc9502d425608fd1e569c1a3642fa8b", destructured_ast = "a6d65ddce050d90d8d253084aa24068e1976e26f04a96110cef71fc841b651ed", inlined_ast = "a6d65ddce050d90d8d253084aa24068e1976e26f04a96110cef71fc841b651ed", dce_ast = "a6d65ddce050d90d8d253084aa24068e1976e26f04a96110cef71fc841b651ed", bytecode = """ program test.aleo; struct A: diff --git a/tests/expectations/compiler/structs/struct_init_out_of_order.out b/tests/expectations/compiler/structs/struct_init_out_of_order.out index 7115eaff7f..3defe98577 100644 --- a/tests/expectations/compiler/structs/struct_init_out_of_order.out +++ b/tests/expectations/compiler/structs/struct_init_out_of_order.out @@ -1,6 +1,6 @@ namespace = "Compile" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "ca7bf7eee449f8c777a7469fa6796b322a48f2e41473fe947476d5b188b5efe8", type_checked_symbol_table = "8652c3474da00cbc5113a3d5551b14dfec8a13b16176262e0f9d283c67ec1439", unrolled_symbol_table = "8652c3474da00cbc5113a3d5551b14dfec8a13b16176262e0f9d283c67ec1439", initial_ast = "38ffc7c2ebcb99ee4a9e936f5566d3de081f67722eab7d87c5a1de167a22430e", unrolled_ast = "38ffc7c2ebcb99ee4a9e936f5566d3de081f67722eab7d87c5a1de167a22430e", ssa_ast = "5c2c8a5ba3777ea8842fb4c8632ba563f84ffc888822043c4c7072862944553d", flattened_ast = "7deb3bedd967ca8e4f02dd2c03c9b77d56a3f9d005220ccee2c13880b900a701", destructured_ast = "59a9f98ca454b037595d7c67fad52659ae3fe74abe176b2df69e3596d1f1d011", inlined_ast = "59a9f98ca454b037595d7c67fad52659ae3fe74abe176b2df69e3596d1f1d011", dce_ast = "59a9f98ca454b037595d7c67fad52659ae3fe74abe176b2df69e3596d1f1d011", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "dd944d121eb2e63f122d2d95a51e2c4ceab0394f4a69c5c3347d57d279126553", type_checked_symbol_table = "9f49e1b9a82ff4aadbecc38d2e90041f8a16b5af3536353547689a83588009b9", unrolled_symbol_table = "9f49e1b9a82ff4aadbecc38d2e90041f8a16b5af3536353547689a83588009b9", initial_ast = "fce4f06c55fcf8d9b056abd03a00b40b5e4aad7d5898b0520f67cc7a06681f0b", unrolled_ast = "fce4f06c55fcf8d9b056abd03a00b40b5e4aad7d5898b0520f67cc7a06681f0b", ssa_ast = "62c3239efb45f0205489ba49fdc70d2054e5f09b62baafaa438606acc6c4ed71", flattened_ast = "b1b84f8aa6e995eedd8981a184ed0795bd0ce733fdf599f76032d66c8a15e302", destructured_ast = "1679e1b28c54bc007f9e989c5941ba5852dd32c8f6f1ce442b62b4f9c10091db", inlined_ast = "1679e1b28c54bc007f9e989c5941ba5852dd32c8f6f1ce442b62b4f9c10091db", dce_ast = "1679e1b28c54bc007f9e989c5941ba5852dd32c8f6f1ce442b62b4f9c10091db", bytecode = """ program test.aleo; struct Foo: diff --git a/tests/expectations/compiler/ternary/ternary_mismatch_fail.out b/tests/expectations/compiler/ternary/ternary_mismatch_fail.out new file mode 100644 index 0000000000..8cfea3d771 --- /dev/null +++ b/tests/expectations/compiler/ternary/ternary_mismatch_fail.out @@ -0,0 +1,11 @@ +namespace = "Compile" +expectation = "Fail" +outputs = [""" +Error [ETYC0372118]: Received different types `u8` and `u16` for the arms of a ternary conditional. + --> compiler-test:5:17 + | + 5 | return (true ? 1u8 : 1u16) as u32; + | ^^^^^^^^^^^^^^^^^ + | + = Make both branches the same type. +"""] diff --git a/tests/expectations/compiler/tuple/access_out_of_bounds_fail.out b/tests/expectations/compiler/tuple/access_out_of_bounds_fail.out index 9577dc7db5..2a80930d9f 100644 --- a/tests/expectations/compiler/tuple/access_out_of_bounds_fail.out +++ b/tests/expectations/compiler/tuple/access_out_of_bounds_fail.out @@ -6,11 +6,6 @@ Error [ETYC0372024]: Tuple index `2` out of range for a tuple with length `2` | 7 | return (t.0, t.2); // Index `t.2` is out of bounds. | ^ -Error [ETYC0372014]: t.2 is not a valid core function call. - --> compiler-test:7:24 - | - 7 | return (t.0, t.2); // Index `t.2` is out of bounds. - | ^ Error [ETYC0372083]: A program must have at least one transition function. --> compiler-test:1:1 | diff --git a/tests/expectations/compiler/tuple/declare_fail.out b/tests/expectations/compiler/tuple/declare_fail.out index e71d8ac63f..4a1f0196f4 100644 --- a/tests/expectations/compiler/tuple/declare_fail.out +++ b/tests/expectations/compiler/tuple/declare_fail.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `bool` but type `u64` was found +Error [ETYC0372117]: Expected type `bool` but type `u64` was found. --> compiler-test:5:35 | 5 | let t: (bool, bool) = (a, 1u64); // We should be declaring to a bool, not a u64. diff --git a/tests/expectations/compiler/tuple/return_statement_fail.out b/tests/expectations/compiler/tuple/return_statement_fail.out index 50c001715f..a0e08a2e29 100644 --- a/tests/expectations/compiler/tuple/return_statement_fail.out +++ b/tests/expectations/compiler/tuple/return_statement_fail.out @@ -1,7 +1,7 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `u64` but type `bool` was found +Error [ETYC0372117]: Expected type `u64` but type `bool` was found. --> compiler-test:7:24 | 7 | return (t.0, t.1); // The second element should be type u64 as in the function declaration. diff --git a/tests/expectations/compiler/tuple/tuple_not_allowed_fail.out b/tests/expectations/compiler/tuple/tuple_not_allowed_fail.out index b8bb0647fe..cd2d78c7b0 100644 --- a/tests/expectations/compiler/tuple/tuple_not_allowed_fail.out +++ b/tests/expectations/compiler/tuple/tuple_not_allowed_fail.out @@ -26,17 +26,17 @@ Error [ETYC0372052]: A tuple expression cannot contain another tuple expression. | 13 | return (1u8, (2u16, 3u32)); | ^^^^^^^^^^^^ -Error [ETYC0372007]: Expected one type from `i8, i16, i32, i64, i128, u8, u16, u32, u64, u128`, but got `(u8,u16)` +Error [ETYC0372117]: Expected an integer but type `(u8, u16)` was found. --> compiler-test:17:13 | 17 | for i: (u8, u16) in 0u8..2u8 {} | ^ -Error [ETYC0372003]: Expected type `(u8,u16)` but type `u8` was found +Error [ETYC0372117]: Expected type `(u8, u16)` but type `u8` was found. --> compiler-test:17:29 | 17 | for i: (u8, u16) in 0u8..2u8 {} | ^^^ -Error [ETYC0372003]: Expected type `(u8,u16)` but type `u8` was found +Error [ETYC0372117]: Expected type `(u8, u16)` but type `u8` was found. --> compiler-test:17:34 | 17 | for i: (u8, u16) in 0u8..2u8 {} diff --git a/tests/expectations/compiler/tuple/type_fail.out b/tests/expectations/compiler/tuple/type_fail.out index da139bbac0..9b48b53dbf 100644 --- a/tests/expectations/compiler/tuple/type_fail.out +++ b/tests/expectations/compiler/tuple/type_fail.out @@ -1,12 +1,12 @@ namespace = "Compile" expectation = "Fail" outputs = [""" -Error [ETYC0372003]: Expected type `u64` but type `bool` was found +Error [ETYC0372117]: Expected type `u64` but type `bool` was found. --> compiler-test:5:34 | 5 | let t: (bool, u64) = (a, b); // We should expect a bool, not a u64. | ^ -Error [ETYC0372003]: Expected type `bool` but type `u64` was found +Error [ETYC0372117]: Expected type `bool` but type `u64` was found. --> compiler-test:7:24 | 7 | return (t.0, t.1); diff --git a/tests/expectations/execution/cast_coersion.out b/tests/expectations/execution/cast_coersion.out index 66679827a0..a85c93cc9f 100644 --- a/tests/expectations/execution/cast_coersion.out +++ b/tests/expectations/execution/cast_coersion.out @@ -1,6 +1,6 @@ namespace = "Execute" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "736ef33d4ea34eb43862ee271decb4587901ab41e91e4f8e41b8f99d1f8b557c", type_checked_symbol_table = "1c73cb243b5146909a9fbd64fb8862bd15578904deaa7ce579d713e635bd0719", unrolled_symbol_table = "1c73cb243b5146909a9fbd64fb8862bd15578904deaa7ce579d713e635bd0719", initial_ast = "409d57cef21ca167d937cf70c1d7c116bc900e502831b395698e9d3f13ae0961", unrolled_ast = "409d57cef21ca167d937cf70c1d7c116bc900e502831b395698e9d3f13ae0961", ssa_ast = "7f12fbc88f56e33590cbb790827e4ec6a04fa9be41e6c1f2bf48515e430d9dc5", flattened_ast = "8e2378df83a8f59228993ec32ae9fbe19318052a3ced6b451b6f720ca6171257", destructured_ast = "8bc445642f52d44cedf36737681f945b99b647953026bb44a836eac1c3cd5d69", inlined_ast = "8bc445642f52d44cedf36737681f945b99b647953026bb44a836eac1c3cd5d69", dce_ast = "2a0e5585007503ef568572b188bae1212a4839548f624b022aafca1ce8e2cf24", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "0bf0ffecff11b7bba089bcff9c95483828b0a1f8a1cb3d3ad670ab4a2721b67a", type_checked_symbol_table = "2146f86583bba1627e873e6ee4415ee359db6c559e9fc3557ee6e0cfa321d4a5", unrolled_symbol_table = "2146f86583bba1627e873e6ee4415ee359db6c559e9fc3557ee6e0cfa321d4a5", initial_ast = "08984708d81bd8c596248ab8d77ce38653a8479679407f3134bcbeebd406f25e", unrolled_ast = "08984708d81bd8c596248ab8d77ce38653a8479679407f3134bcbeebd406f25e", ssa_ast = "54732170d48977af6114f483361ff5784efbca0f148ecc3fc23ff26a16919cbc", flattened_ast = "b3f751879e3e820a6dc1e11f4c1e09a7a4d91ada76d5ffa0822dda82d37b39d0", destructured_ast = "026996b7a2ec5ff49d1f6db2054c2f2178318f1e4bbee471bd4f21a61ed65e8b", inlined_ast = "026996b7a2ec5ff49d1f6db2054c2f2178318f1e4bbee471bd4f21a61ed65e8b", dce_ast = "12d9c436ad74690de1afb37d4e0b5712c1b803dcb83535498cf523e2a5ef9493", bytecode = """ program test.aleo; struct foo: diff --git a/tests/expectations/execution/flattened_function_and_inline_matches.out b/tests/expectations/execution/flattened_function_and_inline_matches.out index a66d4897c0..f0b548ce98 100644 --- a/tests/expectations/execution/flattened_function_and_inline_matches.out +++ b/tests/expectations/execution/flattened_function_and_inline_matches.out @@ -1,6 +1,6 @@ namespace = "Execute" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "33492050657dd82b8780af78e6cbb3768d50f190428f200a6a43472d50a9aa50", type_checked_symbol_table = "f57a951ffd325863f2c35e4b4a4118d3ebbf721a03dd621c731c9a9258af2dbc", unrolled_symbol_table = "f57a951ffd325863f2c35e4b4a4118d3ebbf721a03dd621c731c9a9258af2dbc", initial_ast = "e5ad05937041eea6b511f067c946adc83282a76f09d9c67fd58aba4cddae9d0c", unrolled_ast = "e5ad05937041eea6b511f067c946adc83282a76f09d9c67fd58aba4cddae9d0c", ssa_ast = "c11c83b8011667b9803def78e26c978af8a407a0bc550aa01d57f2a21d64d769", flattened_ast = "c9c69ccdd00a39a9f600ceba6ee7ac5e47c47b1abf8d8857264581cc18795fa6", destructured_ast = "d84d9587cb336791a142e889eb248c425e51acc8f3b8f17561ec1aea5b554378", inlined_ast = "558c25fa346d7e139cb309899cba630557836983ce4f147c2eef009343a670c2", dce_ast = "69876b0a87e8c14ed0085f25354da4a7f2bfaa351dfb5230f9b7f37bcf33d6e3", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "d54d3db6054a70fe892a37383707797a66dd6b2f274f28558d671c90a72be704", type_checked_symbol_table = "9a589915b3ddea542d0b778c13073decd826020d111fa05c6b0b92c194cdbf45", unrolled_symbol_table = "9a589915b3ddea542d0b778c13073decd826020d111fa05c6b0b92c194cdbf45", initial_ast = "02c7bcb8622aac6986250c211adeed9babf124b8b6d26e79c1db69d275ad66cd", unrolled_ast = "02c7bcb8622aac6986250c211adeed9babf124b8b6d26e79c1db69d275ad66cd", ssa_ast = "6aa9dcd46647ae7f9185d3ef2c75d28edb3eaec0b1809871cb5358cdeac48c36", flattened_ast = "1283a2333bc2630dc197151c0d3662c78619e5154270f51ddf8499c2aeb385ba", destructured_ast = "d4bc04c889d5a0c9ba6ab90efec4efb39b3371865d1960cce5546e1bfe41aa02", inlined_ast = "004b6ff49921647b1478d5442aca57908efa1d0aeb5c5febb34faec9fcc21ec4", dce_ast = "0be608a0adef5819ca268b49ebcf4898885a662f249174960bf5e2b21f2cd520", bytecode = """ program test.aleo; struct Extra: diff --git a/tests/expectations/execution/mint.out b/tests/expectations/execution/mint.out index b75e54e78a..8a671ed27b 100644 --- a/tests/expectations/execution/mint.out +++ b/tests/expectations/execution/mint.out @@ -1,6 +1,6 @@ namespace = "Execute" expectation = "Pass" -outputs = [[{ compile = [{ initial_symbol_table = "b1030d2b7e1dc433bcd3691ff89d35caa81dfd394c85f9aa93632c6fdd8ab4b6", type_checked_symbol_table = "231df4a77d82b439bd0d83a23be38e6b0fad8d10817908a60a65a1467aa9e68b", unrolled_symbol_table = "231df4a77d82b439bd0d83a23be38e6b0fad8d10817908a60a65a1467aa9e68b", initial_ast = "bbdd126cd1b3eaeaa719c45b93549653529addb4edd833d367c362e981cdc3e4", unrolled_ast = "daf988283c1682dbbaa69c9588be2654d0d8f161918e696d7a9609854b9e5311", ssa_ast = "92d71ac22b15e4595e2805ead2085b705bdc72550563ef46024e234ceb17e0b8", flattened_ast = "f99c95ce74a5e971118299b787c572047809ea6b45dc7b7d83f6cdb08979e21d", destructured_ast = "3dbc345d506a24072db8e3228eb4bbc99b41df7d673a112d3a351ea493acafb8", inlined_ast = "3dbc345d506a24072db8e3228eb4bbc99b41df7d673a112d3a351ea493acafb8", dce_ast = "3dbc345d506a24072db8e3228eb4bbc99b41df7d673a112d3a351ea493acafb8", bytecode = """ +outputs = [[{ compile = [{ initial_symbol_table = "ea42cc5b0aa60815e040ad1282cc4f70733f8d47bed8659fc3b84598d39231c2", type_checked_symbol_table = "8e0d0ad3588d9dd0d43e18af3b507f9a6911f85e73b24be2eb62dfb65f70b766", unrolled_symbol_table = "8e0d0ad3588d9dd0d43e18af3b507f9a6911f85e73b24be2eb62dfb65f70b766", initial_ast = "7dd4a95e136e980524f0bf5f9d9126b44bfd51487271d4b5281ea1948321fb85", unrolled_ast = "41063270cf057d2f3966a137e9caf6461000e5c90ee530fd5c655720954bfae1", ssa_ast = "bd8f9bf94274dcc82a486bb321df7819943475c745abfdfa8af92c127b069fb9", flattened_ast = "7c5bf66a316a5a0b7f1b1a6208e5f13b6eae630928676874fdb93d1190da72f2", destructured_ast = "b66cb58284923fa9814c2f71fb08a52f50ddfbdf8ee7ce35262cd1c411336c20", inlined_ast = "b66cb58284923fa9814c2f71fb08a52f50ddfbdf8ee7ce35262cd1c411336c20", dce_ast = "b66cb58284923fa9814c2f71fb08a52f50ddfbdf8ee7ce35262cd1c411336c20", bytecode = """ program test.aleo; record Token: diff --git a/tests/expectations/parser/finalize/finalize.out b/tests/expectations/parser/finalize/finalize.out index 7ab35c030c..3cbe21a9f3 100644 --- a/tests/expectations/parser/finalize/finalize.out +++ b/tests/expectations/parser/finalize/finalize.out @@ -28,9 +28,9 @@ functions = [ [ "main", { annotations = [], variant = "AsyncFunction", identifier = '{"id":"13","name":"main","span":"{\"lo\":193,\"hi\":197}"}', id = 23, input = [ - { identifier = '{"id":"14","name":"a","span":"{\"lo\":198,\"hi\":199}"}', mode = "None", id = 16, type_ = { Composite = { id = '{"id":"15","name":"foo","span":"{\"lo\":201,\"hi\":204}"}', program = "test" } }, span = { lo = 198, hi = 204 } }, - { identifier = '{"id":"17","name":"b","span":"{\"lo\":206,\"hi\":207}"}', mode = "None", id = 19, type_ = { Composite = { id = '{"id":"18","name":"bar","span":"{\"lo\":209,\"hi\":212}"}', program = "test" } }, span = { lo = 206, hi = 212 } }, -], output = [{ mode = "None", id = 21, type_ = { Composite = { id = '{"id":"20","name":"baz","span":"{\"lo\":217,\"hi\":220}"}', program = "test" } }, span = { lo = 217, hi = 220 } }], output_type = { Composite = { id = '{"id":"20","name":"baz","span":"{\"lo\":217,\"hi\":220}"}', program = "test" } }, block = { statements = [], id = 22, span = { lo = 221, hi = 233 } }, span = { lo = 178, hi = 233 } }, + { identifier = '{"id":"14","name":"a","span":"{\"lo\":198,\"hi\":199}"}', mode = "None", id = 16, type_ = { Composite = { id = '{"id":"15","name":"foo","span":"{\"lo\":201,\"hi\":204}"}' } }, span = { lo = 198, hi = 204 } }, + { identifier = '{"id":"17","name":"b","span":"{\"lo\":206,\"hi\":207}"}', mode = "None", id = 19, type_ = { Composite = { id = '{"id":"18","name":"bar","span":"{\"lo\":209,\"hi\":212}"}' } }, span = { lo = 206, hi = 212 } }, +], output = [{ mode = "None", id = 21, type_ = { Composite = { id = '{"id":"20","name":"baz","span":"{\"lo\":217,\"hi\":220}"}' } }, span = { lo = 217, hi = 220 } }], output_type = { Composite = { id = '{"id":"20","name":"baz","span":"{\"lo\":217,\"hi\":220}"}' } }, block = { statements = [], id = 22, span = { lo = 221, hi = 233 } }, span = { lo = 178, hi = 233 } }, ], ] diff --git a/tests/expectations/parser/finalize/mapping.out b/tests/expectations/parser/finalize/mapping.out index 2a51c03703..5003d03afa 100644 --- a/tests/expectations/parser/finalize/mapping.out +++ b/tests/expectations/parser/finalize/mapping.out @@ -14,7 +14,7 @@ structs = [] mappings = [ [ "foo", - { identifier = '{"id":"2","name":"foo","span":"{\"lo\":38,\"hi\":41}"}', id = 5, key_type = { Composite = { id = '{"id":"3","name":"bar","span":"{\"lo\":43,\"hi\":46}"}', program = "test" } }, value_type = { Composite = { id = '{"id":"4","name":"baz","span":"{\"lo\":50,\"hi\":53}"}', program = "test" } }, span = { lo = 30, hi = 54 } }, + { identifier = '{"id":"2","name":"foo","span":"{\"lo\":38,\"hi\":41}"}', id = 5, key_type = { Composite = { id = '{"id":"3","name":"bar","span":"{\"lo\":43,\"hi\":46}"}' } }, value_type = { Composite = { id = '{"id":"4","name":"baz","span":"{\"lo\":50,\"hi\":53}"}' } }, span = { lo = 30, hi = 54 } }, ], [ "foo", diff --git a/tests/expectations/parser/program/mapping.out b/tests/expectations/parser/program/mapping.out index dcc19a4848..6b8d474851 100644 --- a/tests/expectations/parser/program/mapping.out +++ b/tests/expectations/parser/program/mapping.out @@ -18,7 +18,7 @@ mappings = [ ], [ "foo", - { identifier = '{"id":"4","name":"foo","span":"{\"lo\":82,\"hi\":85}"}', id = 7, key_type = { Composite = { id = '{"id":"5","name":"bar","span":"{\"lo\":87,\"hi\":90}"}', program = "test" } }, value_type = { Composite = { id = '{"id":"6","name":"baz","span":"{\"lo\":94,\"hi\":97}"}', program = "test" } }, span = { lo = 74, hi = 98 } }, + { identifier = '{"id":"4","name":"foo","span":"{\"lo\":82,\"hi\":85}"}', id = 7, key_type = { Composite = { id = '{"id":"5","name":"bar","span":"{\"lo\":87,\"hi\":90}"}' } }, value_type = { Composite = { id = '{"id":"6","name":"baz","span":"{\"lo\":94,\"hi\":97}"}' } }, span = { lo = 74, hi = 98 } }, ], ] functions = [] diff --git a/tests/expectations/parser/type_/signature.out b/tests/expectations/parser/type_/signature.out index bda7d3c80d..5088b5f746 100644 --- a/tests/expectations/parser/type_/signature.out +++ b/tests/expectations/parser/type_/signature.out @@ -18,7 +18,7 @@ functions = [ { annotations = [], variant = "Transition", identifier = '{"id":"2","name":"baz","span":"{\"lo\":37,\"hi\":40}"}', output = [], output_type = "Unit", id = 30, input = [ { identifier = '{"id":"3","name":"s","span":"{\"lo\":41,\"hi\":42}"}', mode = "None", type_ = "Signature", id = 4, span = { lo = 41, hi = 53 } }, { identifier = '{"id":"5","name":"a","span":"{\"lo\":55,\"hi\":56}"}', mode = "None", type_ = "Address", id = 6, span = { lo = 55, hi = 65 } }, - { identifier = '{"id":"7","name":"v","span":"{\"lo\":67,\"hi\":68}"}', mode = "None", id = 9, type_ = { Composite = { id = '{"id":"8","name":"value","span":"{\"lo\":70,\"hi\":75}"}', program = "test" } }, span = { lo = 67, hi = 75 } }, + { identifier = '{"id":"7","name":"v","span":"{\"lo\":67,\"hi\":68}"}', mode = "None", id = 9, type_ = { Composite = { id = '{"id":"8","name":"value","span":"{\"lo\":70,\"hi\":75}"}' } }, span = { lo = 67, hi = 75 } }, ], block = { id = 29, statements = [ { Definition = { declaration_type = "Let", type_ = "Boolean", id = 17, place = { Identifier = '{"id":"10","name":"a","span":"{\"lo\":91,\"hi\":92}"}' }, value = { Access = { AssociatedFunction = { variant = '{"id":"11","name":"signature","span":"{\"lo\":101,\"hi\":110}"}', name = '{"id":"12","name":"verify","span":"{\"lo\":112,\"hi\":118}"}', id = 16, arguments = [ { Identifier = '{"id":"13","name":"s","span":"{\"lo\":119,\"hi\":120}"}' }, @@ -53,7 +53,7 @@ functions = [ { annotations = [], variant = "Transition", identifier = '{"id":"44","name":"bax","span":"{\"lo\":317,\"hi\":320}"}', output = [], output_type = "Unit", id = 64, input = [ { identifier = '{"id":"45","name":"s","span":"{\"lo\":321,\"hi\":322}"}', mode = "None", type_ = "Signature", id = 46, span = { lo = 321, hi = 333 } }, { identifier = '{"id":"47","name":"a","span":"{\"lo\":335,\"hi\":336}"}', mode = "None", type_ = "Address", id = 48, span = { lo = 335, hi = 345 } }, - { identifier = '{"id":"49","name":"v","span":"{\"lo\":347,\"hi\":348}"}', mode = "None", id = 51, type_ = { Composite = { id = '{"id":"50","name":"value","span":"{\"lo\":350,\"hi\":355}"}', program = "test" } }, span = { lo = 347, hi = 355 } }, + { identifier = '{"id":"49","name":"v","span":"{\"lo\":347,\"hi\":348}"}', mode = "None", id = 51, type_ = { Composite = { id = '{"id":"50","name":"value","span":"{\"lo\":350,\"hi\":355}"}' } }, span = { lo = 347, hi = 355 } }, ], block = { id = 63, statements = [ { Definition = { declaration_type = "Let", type_ = "Boolean", id = 59, place = { Identifier = '{"id":"52","name":"a","span":"{\"lo\":370,\"hi\":371}"}' }, value = { Access = { AssociatedFunction = { variant = '{"id":"53","name":"signature","span":"{\"lo\":380,\"hi\":389}"}', name = '{"id":"54","name":"sign","span":"{\"lo\":391,\"hi\":395}"}', id = 58, arguments = [ { Identifier = '{"id":"55","name":"s","span":"{\"lo\":396,\"hi\":397}"}' }, diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i128.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i128.leo index 4f8b25c87f..9baa36abd2 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i128.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i128.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i16.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i16.leo index cf6d008782..96851d4eae 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i16.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i16.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i32.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i32.leo index 1641fafde5..6e95757e56 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i32.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i32.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i64.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i64.leo index 4999280d03..2b08650f5a 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i64.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i64.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i8.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i8.leo index db6d1ef8ed..56adf2dda6 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i8.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_i8.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u128.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u128.leo index a8fec57862..506c8749f2 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u128.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u128.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u16.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u16.leo index d62473a4b6..efa9b83603 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u16.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u16.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u32.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u32.leo index 042e75ae82..1ef1bcd495 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u32.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u32.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u64.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u64.leo index dd9da9b83e..1630d2f0c8 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u64.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u64.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u8.leo b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u8.leo index 2e2013d54a..16fbca3773 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u8.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen128/pedersen128_hash_to_u8.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i128.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i128.leo index 3aa6aa0ff0..3d477198a2 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i128.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i128.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i16.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i16.leo index 9d7178dc84..32e7112121 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i16.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i16.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i32.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i32.leo index 5f50677a43..67059d5cc9 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i32.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i32.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i64.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i64.leo index 1895870269..1b74cadd01 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i64.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i64.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i8.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i8.leo index 37b4d26edd..3e9fbc3889 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i8.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_i8.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u128.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u128.leo index cf1330e41e..520c8c3e49 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u128.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u128.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u16.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u16.leo index b41e54c79f..ed2101763e 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u16.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u16.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u32.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u32.leo index 1385c21856..f20f105a88 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u32.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u32.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u64.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u64.leo index 3867c486f8..9ae76f7e7d 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u64.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u64.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u8.leo b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u8.leo index 997a7c707e..ca12a5ab3b 100644 --- a/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u8.leo +++ b/tests/tests/compiler/core/algorithms/integers/pedersen64/pedersen64_hash_to_u8.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen128_commit_to_address.leo b/tests/tests/compiler/core/algorithms/pedersen128_commit_to_address.leo index a906ceb39c..d1f0c4947c 100644 --- a/tests/tests/compiler/core/algorithms/pedersen128_commit_to_address.leo +++ b/tests/tests/compiler/core/algorithms/pedersen128_commit_to_address.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen128_commit_to_field.leo b/tests/tests/compiler/core/algorithms/pedersen128_commit_to_field.leo index b7fb885aae..263224ba4d 100644 --- a/tests/tests/compiler/core/algorithms/pedersen128_commit_to_field.leo +++ b/tests/tests/compiler/core/algorithms/pedersen128_commit_to_field.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen128_commit_to_group.leo b/tests/tests/compiler/core/algorithms/pedersen128_commit_to_group.leo index 94b36e5a20..3a777b847d 100644 --- a/tests/tests/compiler/core/algorithms/pedersen128_commit_to_group.leo +++ b/tests/tests/compiler/core/algorithms/pedersen128_commit_to_group.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen128_hash_to_address.leo b/tests/tests/compiler/core/algorithms/pedersen128_hash_to_address.leo index 9dddbdea41..528ded18a1 100644 --- a/tests/tests/compiler/core/algorithms/pedersen128_hash_to_address.leo +++ b/tests/tests/compiler/core/algorithms/pedersen128_hash_to_address.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen128_hash_to_field.leo b/tests/tests/compiler/core/algorithms/pedersen128_hash_to_field.leo index 27c89acc35..dbe0ba9168 100644 --- a/tests/tests/compiler/core/algorithms/pedersen128_hash_to_field.leo +++ b/tests/tests/compiler/core/algorithms/pedersen128_hash_to_field.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen128_hash_to_group.leo b/tests/tests/compiler/core/algorithms/pedersen128_hash_to_group.leo index 8a64234b3c..e591f8f19a 100644 --- a/tests/tests/compiler/core/algorithms/pedersen128_hash_to_group.leo +++ b/tests/tests/compiler/core/algorithms/pedersen128_hash_to_group.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen64_commit_to_address.leo b/tests/tests/compiler/core/algorithms/pedersen64_commit_to_address.leo index c36d479e7d..fda7525c27 100644 --- a/tests/tests/compiler/core/algorithms/pedersen64_commit_to_address.leo +++ b/tests/tests/compiler/core/algorithms/pedersen64_commit_to_address.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen64_commit_to_field.leo b/tests/tests/compiler/core/algorithms/pedersen64_commit_to_field.leo index e885c33ad1..ac20ac27ec 100644 --- a/tests/tests/compiler/core/algorithms/pedersen64_commit_to_field.leo +++ b/tests/tests/compiler/core/algorithms/pedersen64_commit_to_field.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen64_commit_to_group.leo b/tests/tests/compiler/core/algorithms/pedersen64_commit_to_group.leo index b94363498d..e676302ebf 100644 --- a/tests/tests/compiler/core/algorithms/pedersen64_commit_to_group.leo +++ b/tests/tests/compiler/core/algorithms/pedersen64_commit_to_group.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen64_hash_to_address.leo b/tests/tests/compiler/core/algorithms/pedersen64_hash_to_address.leo index 853515f0c8..7917b31748 100644 --- a/tests/tests/compiler/core/algorithms/pedersen64_hash_to_address.leo +++ b/tests/tests/compiler/core/algorithms/pedersen64_hash_to_address.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen64_hash_to_field.leo b/tests/tests/compiler/core/algorithms/pedersen64_hash_to_field.leo index 1b4105943d..973ea07d84 100644 --- a/tests/tests/compiler/core/algorithms/pedersen64_hash_to_field.leo +++ b/tests/tests/compiler/core/algorithms/pedersen64_hash_to_field.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen64_hash_to_group.leo b/tests/tests/compiler/core/algorithms/pedersen64_hash_to_group.leo index b63625fe75..85e42863d5 100644 --- a/tests/tests/compiler/core/algorithms/pedersen64_hash_to_group.leo +++ b/tests/tests/compiler/core/algorithms/pedersen64_hash_to_group.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/core/algorithms/pedersen64_hash_to_scalar.leo b/tests/tests/compiler/core/algorithms/pedersen64_hash_to_scalar.leo index 71777c292e..601f2c506d 100644 --- a/tests/tests/compiler/core/algorithms/pedersen64_hash_to_scalar.leo +++ b/tests/tests/compiler/core/algorithms/pedersen64_hash_to_scalar.leo @@ -1,6 +1,6 @@ /* namespace = "Compile" -expectation = "Pass" +expectation = "Fail" */ program test.aleo { diff --git a/tests/tests/compiler/futures/async_before_call_fail.leo b/tests/tests/compiler/futures/async_before_call_fail.leo new file mode 100644 index 0000000000..e437122bb6 --- /dev/null +++ b/tests/tests/compiler/futures/async_before_call_fail.leo @@ -0,0 +1,22 @@ +/* +namespace = "Compile" +expectation = "Fail" +*/ + +program child.aleo { + transition t() {} +} + + // --- Next Program --- // + +import child.aleo; + +program parent.aleo { + async transition foo() -> Future { + let future: Future = finalize_foo(); + child.aleo/t(); + return future; + } + + async function finalize_foo() {} +} diff --git a/tests/tests/compiler/operations/abs_type_fail.leo b/tests/tests/compiler/operations/abs_type_fail.leo new file mode 100644 index 0000000000..5e7b544c57 --- /dev/null +++ b/tests/tests/compiler/operations/abs_type_fail.leo @@ -0,0 +1,10 @@ +/* +namespace = "Compile" +expectation = "Fail" +*/ + +program test.aleo { + transition main() -> u8 { + return (true ? 1u16.abs() : 2u16.abs()) as u8; + } +} diff --git a/tests/tests/compiler/operations/add_type_fail.leo b/tests/tests/compiler/operations/add_type_fail.leo new file mode 100644 index 0000000000..8a0c918c45 --- /dev/null +++ b/tests/tests/compiler/operations/add_type_fail.leo @@ -0,0 +1,10 @@ +/* +namespace = "Compile" +expectation = "Fail" +*/ + +program test.aleo { + transition main() -> u8 { + return (true + false) as u8; + } +} diff --git a/tests/tests/compiler/records/duplicate_circuit_name_fail.leo b/tests/tests/compiler/records/duplicate_circuit_name_fail.leo index 509fd38e40..530cd6c0f7 100644 --- a/tests/tests/compiler/records/duplicate_circuit_name_fail.leo +++ b/tests/tests/compiler/records/duplicate_circuit_name_fail.leo @@ -3,18 +3,18 @@ namespace = "Compile" expectation = "Fail" */ -program test.aleo { +program test.aleo { record Token { // The token owner. owner: address, // The token amount. amount: u64, } - + struct Token { // This struct cannot have the same name as the record defined above it. x: u32, } - + function main(zz: bool) -> bool { return true; }} diff --git a/tests/tests/compiler/records/same_name_diff_type_fail.leo b/tests/tests/compiler/records/same_name_diff_type_fail.leo new file mode 100644 index 0000000000..892d903da0 --- /dev/null +++ b/tests/tests/compiler/records/same_name_diff_type_fail.leo @@ -0,0 +1,37 @@ +/* +namespace = "Compile" +expectation = "Fail" +*/ + +program child.aleo { + record R { + owner: address, + x: u8, + } + + transition create() -> R { + return R { + owner: self.caller, + x: 1u8, + }; + } +} + +// --- Next Program --- // + +import child.aleo; +program parent.aleo { + record R { + owner: address, + x: u16, + } + + transition check() -> bool { + let r1: R = R { + owner: self.caller, + x: 1u16, + }; + + return r1 == child.aleo/create(); + } +} diff --git a/tests/tests/compiler/ternary/ternary_mismatch_fail.leo b/tests/tests/compiler/ternary/ternary_mismatch_fail.leo new file mode 100644 index 0000000000..0d7cb0fca3 --- /dev/null +++ b/tests/tests/compiler/ternary/ternary_mismatch_fail.leo @@ -0,0 +1,10 @@ +/* +namespace = "Compile" +expectation = "Fail" +*/ + +program test.aleo { + transition main() -> u32 { + return (true ? 1u8 : 1u16) as u32; + } +}