checker: fix compiler panic, when calling an unknown function in C.printf(c'%f\n', sin(2)) (fix #22343) (#22348)

This commit is contained in:
Felipe Pena 2024-09-29 02:02:38 -03:00 committed by GitHub
parent 161d29a922
commit 80e09e2f91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 1 deletions

View File

@ -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)
}

View File

@ -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 | }

View File

@ -0,0 +1,5 @@
module main
fn main() {
C.printf(c'%f\n', sin(2))
}