Skip to content

Commit

Permalink
fix crash for $limit() with 1 arg
Browse files Browse the repository at this point in the history
  • Loading branch information
gjcoram committed Jun 22, 2024
1 parent ed5641e commit 9b0c59b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions openvaf/hir_ty/src/inference.rs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,9 @@ impl Ctx<'_> {
}

BuiltIn::limit => {
infere_args = &args[0..2];
if args.len() >= 2 {
infere_args = &args[0..2];
}
Cow::Borrowed(TiSlice::from_ref(info.signatures))
}

Expand Down Expand Up @@ -787,11 +789,13 @@ impl Ctx<'_> {
self.result.diagnostics.push(InferenceDiagnostic::ExpectedProbe { e: probe })
}

if let Some(Ty::UserFunction(func)) = self.result.expr_types.get(args[1]).cloned() {
if args.len() == 1 {
// only one argument (no limit function specified)
} else if let Some(Ty::UserFunction(func)) = self.result.expr_types.get(args[1]).cloned() {
debug_assert_eq!(sig, LIMIT_USER_FUNCTION);
let fun_info = self.db.function_data(func);

// user-function needs two extra arguments but $limit also accepts two accepts that are
// user-function needs two extra arguments but $limit also accepts two arguments that are
// not passed directly to the function so these must just be equal
if fun_info.args.len() != args.len() {
self.result.diagnostics.push(InferenceDiagnostic::ArgCntMismatch {
Expand Down

0 comments on commit 9b0c59b

Please sign in to comment.