From a6016530f1ed40cb7248c2dc27e8db158f0c943d Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Wed, 29 May 2024 17:38:16 +0300 Subject: [PATCH] ci,cgen: put the `Interface(unsafe{nil})` change for now behind -experimental (#21593) --- vlib/v/gen/c/cgen.v | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 860e0ad076..f54e0014fe 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -2564,12 +2564,14 @@ fn (mut g Gen) expr_with_cast(expr ast.Expr, got_type_raw ast.Type, expected_typ if exp_sym.info.is_generic { fname = g.generic_fn_name(exp_sym.info.concrete_types, fname) } - // Do not allocate for `Interface(unsafe{nil})` casts - is_nil_cast := expr is ast.UnsafeExpr && expr.expr is ast.Nil - if is_nil_cast { - g.write('/*nili*/') - g.write('((void*)0)') - return + if g.pref.experimental { + // Do not allocate for `Interface(unsafe{nil})` casts + is_nil_cast := expr is ast.UnsafeExpr && expr.expr is ast.Nil + if is_nil_cast { + g.write('/*nili*/') + g.write('((void*)0)') + return + } } g.call_cfn_for_casting_expr(fname, expr, expected_is_ptr, exp_styp, got_is_ptr, false, got_styp)