Skip to content

Commit

Permalink
checker: fix compiler panic, when calling an unknown function in `C.p…
Browse files Browse the repository at this point in the history
…rintf(c'%f\n', sin(2))` (fix #22343) (#22348)
  • Loading branch information
felipensp authored Sep 29, 2024
1 parent 161d29a commit 80e09e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
c.expected_type = expected_type
}
typ := if already_checked && mut call_arg.expr is ast.CallExpr {
call_arg.expr.return_type
node.args[i].typ
} else {
c.expr(mut call_arg.expr)
}
Expand Down
6 changes: 6 additions & 0 deletions vlib/v/checker/tests/unknown_fn_call_err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
vlib/v/checker/tests/unknown_fn_call_err.vv:4:20: error: unknown function: sin
2 |
3 | fn main() {
4 | C.printf(c'%f\n', sin(2))
| ~~~~~~
5 | }
5 changes: 5 additions & 0 deletions vlib/v/checker/tests/unknown_fn_call_err.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module main

fn main() {
C.printf(c'%f\n', sin(2))
}

0 comments on commit 80e09e2

Please sign in to comment.