make return statement optional
This commit is contained in:
parent
8057d2714d
commit
ea98c92879
4 changed files with 30 additions and 9 deletions
|
@ -1,5 +0,0 @@
|
||||||
def foo() {}
|
|
||||||
|
|
||||||
def main() {
|
|
||||||
return;
|
|
||||||
}
|
|
|
@ -1186,11 +1186,23 @@ impl<'ast, T: Field> Checker<'ast, T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !found_return {
|
if !found_return {
|
||||||
|
match &s.output {
|
||||||
|
box DeclarationType::Tuple(tuple_type)
|
||||||
|
if tuple_type.elements.is_empty() =>
|
||||||
|
{
|
||||||
|
statements_checked.push(TypedStatement::Return(TypedExpression::Tuple(
|
||||||
|
TupleExpressionInner::Value(vec![])
|
||||||
|
.annotate(TupleType::new(vec![])),
|
||||||
|
)))
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
errors.push(ErrorInner {
|
errors.push(ErrorInner {
|
||||||
pos: Some(pos),
|
pos: Some(pos),
|
||||||
message: "Expected a return statement".to_string(),
|
message: "Expected a return statement".to_string(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
signature = Some(s);
|
signature = Some(s);
|
||||||
}
|
}
|
||||||
|
|
5
zokrates_core_test/tests/tests/no_return.json
Normal file
5
zokrates_core_test/tests/tests/no_return.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"entry_point": "./tests/tests/no_return.zok",
|
||||||
|
"tests": [
|
||||||
|
]
|
||||||
|
}
|
9
zokrates_core_test/tests/tests/no_return.zok
Normal file
9
zokrates_core_test/tests/tests/no_return.zok
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
def foo() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
def bar() {
|
||||||
|
return foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
def main() {}
|
Loading…
Reference in a new issue