fix multiple assignment bug

This commit is contained in:
collin 2020-04-27 17:15:54 -07:00
parent 1dcaa06ef0
commit 48ab4747e0
2 changed files with 10 additions and 14 deletions

View File

@ -1,11 +1,9 @@
function main(a: private bool) -> (u32) {
b = 0;
for i in 0..4 {
if (a) {
return 9
} else {
b = b + i;
}
}
return b
function test() -> (u32, u32[2]) {
return 1, [2, 3]
}
function main() -> (u32[3]) {
a, b = test();
// a, u32[2] b = test() <- explicit type also works
return [a, ...b]
}

View File

@ -303,12 +303,10 @@ impl<F: Field + PrimeField, CS: ConstraintSystem<F>> ResolvedProgram<F, CS> {
// this function call is inline so we unwrap the return value
match self.enforce_function(cs, file_scope, function, arguments) {
ResolvedValue::Return(return_values) => {
if return_values.len() == 0 {
ResolvedValue::Return(vec![])
} else if return_values.len() == 1 {
if return_values.len() == 1 {
return_values[0].clone()
} else {
unimplemented!("function {} returns multiple values but is used in an expression that expects one", function_name)
ResolvedValue::Return(return_values)
}
}
value => unimplemented!(