zkas: fix panic occurring in nested function calls

This issue was discovered by fuzzing.

Change the `unimplemented()!` panic macro to error handling that informs
the user that using Literals and Functions in nested function calls is
not yet supported. This should be a slightly more friendly developer
experience. Changing this from a panic to an error allows us to continue
with further fuzzing.
This commit is contained in:
y
2023-09-17 12:47:58 -04:00
committed by parazyd
parent 3b52ed4e27
commit 0a61ec37fb

View File

@@ -186,6 +186,8 @@ impl Analyzer {
let mut rhs_inner = vec![];
for (inner_idx, i) in func.rhs.iter().enumerate() {
// TODO: Implement cases where `i` is type Arg::Literal
// TODO: Implement cases where `i` is type Arg::Func
if let Arg::Var(v) = i {
if let Some(var_ref) = self.lookup_var(&v.name) {
let (var_type, ln, col) = match var_ref {
@@ -218,8 +220,20 @@ impl Analyzer {
v.line,
v.column,
))
} else if let Arg::Lit(l) = i {
return Err(self.error.abort(
&format!("Expected argument `{}` to be of type Variable. Literals are not yet supported in nested function calls.", l.name),
l.line,
l.column,
))
} else if let Arg::Func(f) = i {
return Err(self.error.abort(
&format!("Expected argument `{}` to be of type Variable. Nested function calls are not yet supported beyond a depth of 1.", Opcode::name(&f.opcode)),
f.line,
0,
))
} else {
unimplemented!()
unreachable!();
}
}