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:
parent
273f46f810
commit
1e88b1ab3e
@ -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} );')
|
||||
}
|
||||
|
5
vlib/v/slow_tests/inout/option_panic.out
Normal file
5
vlib/v/slow_tests/inout/option_panic.out
Normal 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
|
8
vlib/v/slow_tests/inout/option_panic.vv
Normal file
8
vlib/v/slow_tests/inout/option_panic.vv
Normal file
@ -0,0 +1,8 @@
|
||||
fn t() ? {
|
||||
a := ?string(none)
|
||||
println(a?)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
t()?
|
||||
}
|
Loading…
Reference in New Issue
Block a user