mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-28 01:01:53 +03:00
fix array function input bug
This commit is contained in:
parent
9bae1037f7
commit
b3c140d5bb
@ -16,7 +16,6 @@
|
||||
|
||||
use crate::{
|
||||
assert_satisfied,
|
||||
expect_compiler_error,
|
||||
expect_dynamic_check_error,
|
||||
generate_main_input,
|
||||
get_output,
|
||||
@ -42,9 +41,9 @@ fn test_arguments_length_fail() {
|
||||
#[test]
|
||||
fn test_arguments_type_fail() {
|
||||
let program_bytes = include_bytes!("arguments_type_fail.leo");
|
||||
let program = parse_program(program_bytes).unwrap();
|
||||
let error = parse_program(program_bytes).err().unwrap();
|
||||
|
||||
expect_compiler_error(program);
|
||||
expect_dynamic_check_error(error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
6
compiler/tests/function/array_input.leo
Normal file
6
compiler/tests/function/array_input.leo
Normal file
@ -0,0 +1,6 @@
|
||||
function foo(a: [u8; 1]) {}
|
||||
|
||||
function main() {
|
||||
let a: [u16; 1] = [1; 1];
|
||||
foo(a);
|
||||
}
|
@ -133,6 +133,14 @@ fn test_value_unchanged() {
|
||||
assert_satisfied(program);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_array_input() {
|
||||
let bytes = include_bytes!("array_input.leo");
|
||||
let error = parse_program(bytes).err().unwrap();
|
||||
|
||||
expect_dynamic_check_error(error)
|
||||
}
|
||||
|
||||
// Test return multidimensional arrays
|
||||
|
||||
#[test]
|
||||
|
@ -1050,8 +1050,6 @@ impl Frame {
|
||||
.ok_or_else(|| FrameError::undefined_circuit(identifier))?
|
||||
};
|
||||
|
||||
println!("circuit_type: {:?}", circuit_type);
|
||||
|
||||
// Check the length of the circuit members.
|
||||
if circuit_type.variables.len() != members.len() {
|
||||
return Err(FrameError::num_variables(
|
||||
|
@ -238,10 +238,19 @@ impl Type {
|
||||
/// Replaces self with the given type if self is equal to the given `TypeVariable`.
|
||||
///
|
||||
pub fn substitute(&mut self, variable: &TypeVariable, type_: &Type) {
|
||||
if let Type::TypeVariable(self_variable) = self {
|
||||
if self_variable == variable {
|
||||
*self = type_.to_owned()
|
||||
match self {
|
||||
Type::TypeVariable(self_variable) => {
|
||||
if self_variable == variable {
|
||||
*self = type_.to_owned()
|
||||
}
|
||||
}
|
||||
Type::Array(self_type, _) => {
|
||||
self_type.substitute(variable, type_);
|
||||
}
|
||||
Type::Tuple(types) => types
|
||||
.iter_mut()
|
||||
.for_each(|tuple_type| tuple_type.substitute(variable, type_)),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user