From eaf8b63dd2dd5708b169ef6abf6612d377494851 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Sun, 8 Aug 2021 06:23:22 +0300 Subject: [PATCH] cgen: fix a c2v bug with variadics --- vlib/v/ast/table.v | 2 ++ vlib/v/gen/c/fn.v | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index ae8ae054e8..11a096c597 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -39,6 +39,7 @@ pub mut: // When table.gostmts > 0, __VTHREADS__ is defined, which can be checked with `$if threads {` } +/* [unsafe] pub fn (t &Table) free() { unsafe { @@ -58,6 +59,7 @@ pub fn (t &Table) free() { t.used_vweb_types.free() } } +*/ pub type FnPanicHandler = fn (&Table, string) diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index 5f4cf7603f..29a9cac81d 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -1227,7 +1227,12 @@ fn (mut g Gen) call_args(node ast.CallExpr) { } } elem_type := g.typ(arr_info.elem_type) - if args.len > 0 && args[args.len - 1].expr is ast.ArrayDecompose { + if g.pref.translated && args.len == 1 { + // Handle `foo(c'str')` for `fn foo(args ...&u8)` + // TODO handle this in a better place + // println(g.table.type_to_str(args[0].typ)) + g.expr(args[0].expr) + } else if args.len > 0 && args[args.len - 1].expr is ast.ArrayDecompose { g.expr(args[args.len - 1].expr) } else { if variadic_count > 0 {