From 7f67981637dedf2d5d12f6d44a49844c46510915 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 6 Jun 2022 13:24:33 +0300 Subject: [PATCH] checker: allow literal args as references in translated code --- vlib/v/checker/fn.v | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 523990a607..7f6577be54 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -898,7 +898,7 @@ pub fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) continue } if param.typ.is_ptr() && !param.is_mut && !call_arg.typ.is_real_pointer() - && call_arg.expr.is_literal() && func.language == .v { + && call_arg.expr.is_literal() && func.language == .v && !c.pref.translated { c.error('literal argument cannot be passed as reference parameter `${c.table.type_to_str(param.typ)}`', call_arg.pos) } @@ -1438,7 +1438,8 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type { } continue } - if param.typ.is_ptr() && !arg.typ.is_real_pointer() && arg.expr.is_literal() { + if param.typ.is_ptr() && !arg.typ.is_real_pointer() && arg.expr.is_literal() + && !c.pref.translated { c.error('literal argument cannot be passed as reference parameter `${c.table.type_to_str(param.typ)}`', arg.pos) }