diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 85434893ee..fd958d8007 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -5958,7 +5958,7 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty err_msg := 'IError_name_table[${cvar_name}.err._typ]._method_msg(${cvar_name}.err._object)' if g.pref.is_debug { paline, pafile, pamod, pafn := g.panic_debug_info(or_block.pos) - g.writeln('panic_debug(${paline}, tos3("${pafile}"), tos3("${pamod}"), tos3("${pafn}"), ${err_msg} );') + g.writeln('panic_debug(${paline}, tos3("${pafile}"), tos3("${pamod}"), tos3("${pafn}"), ${err_msg}.len == 0 ? _SLIT("option not set ()") : ${err_msg});') } else { g.writeln('\tpanic_option_not_set( ${err_msg} );') } diff --git a/vlib/v/slow_tests/inout/option_panic.out b/vlib/v/slow_tests/inout/option_panic.out new file mode 100644 index 0000000000..d80b7e2f97 --- /dev/null +++ b/vlib/v/slow_tests/inout/option_panic.out @@ -0,0 +1,5 @@ +================ V panic ================ + module: main + function: main() + message: option not set () + file: vlib/v/slow_tests/inout/option_panic.vv:7 \ No newline at end of file diff --git a/vlib/v/slow_tests/inout/option_panic.vv b/vlib/v/slow_tests/inout/option_panic.vv new file mode 100644 index 0000000000..30768d355c --- /dev/null +++ b/vlib/v/slow_tests/inout/option_panic.vv @@ -0,0 +1,8 @@ +fn t() ? { + a := ?string(none) + println(a?) +} + +fn main() { + t()? +}