1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix missing panic message for 'option not set' on debug (#18168)

This commit is contained in:
Felipe Pena 2023-05-18 06:25:19 -03:00 committed by GitHub
parent 273f46f810
commit 1e88b1ab3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View File

@ -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)' err_msg := 'IError_name_table[${cvar_name}.err._typ]._method_msg(${cvar_name}.err._object)'
if g.pref.is_debug { if g.pref.is_debug {
paline, pafile, pamod, pafn := g.panic_debug_info(or_block.pos) 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 { } else {
g.writeln('\tpanic_option_not_set( ${err_msg} );') g.writeln('\tpanic_option_not_set( ${err_msg} );')
} }

View File

@ -0,0 +1,5 @@
================ V panic ================
module: main
function: main()
message: option not set ()
file: vlib/v/slow_tests/inout/option_panic.vv:7

View File

@ -0,0 +1,8 @@
fn t() ? {
a := ?string(none)
println(a?)
}
fn main() {
t()?
}