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,10 +1186,22 @@ impl<'ast, T: Field> Checker<'ast, T> {
|
|||
}
|
||||
|
||||
if !found_return {
|
||||
errors.push(ErrorInner {
|
||||
pos: Some(pos),
|
||||
message: "Expected a return statement".to_string(),
|
||||
});
|
||||
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 {
|
||||
pos: Some(pos),
|
||||
message: "Expected a return statement".to_string(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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