cgen: improve diagnostic for a v compiler panic in dicordv

pull/12424/head
Delyan Angelov 2021-11-10 08:12:12 +02:00
parent 8f4180ea09
commit 6c244d3065
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
1 changed files with 8 additions and 1 deletions

View File

@ -1296,7 +1296,14 @@ fn (mut g Gen) autofree_call_postgen(node_pos int) {
}
fn (mut g Gen) call_args(node ast.CallExpr) {
args := if g.is_js_call { node.args[1..] } else { node.args }
args := if g.is_js_call {
if node.args.len < 1 {
g.error('node should have at least 1 arg', node.pos)
}
node.args[1..]
} else {
node.args
}
expected_types := node.expected_arg_types
// only v variadic, C variadic args will be appeneded like normal args
is_variadic := expected_types.len > 0 && expected_types.last().has_flag(.variadic)