Skip to content

Commit

Permalink
builtin: remove string interpolation from panic/1, to be able to use …
Browse files Browse the repository at this point in the history
…tools like cbmc in more cases (#22182)
  • Loading branch information
spytheman authored Sep 9, 2024
1 parent ac6ca5f commit 6528efa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions vlib/builtin/builtin.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,14 @@ pub fn panic_result_not_set(s string) {
// It also shows a backtrace on most platforms.
@[noreturn]
pub fn panic(s string) {
// Note: be careful to not use string interpolation here:
$if freestanding {
bare_panic(s)
} $else {
eprint('V panic: ')
eprintln(s)
eprintln('v hash: ${@VCURRENTHASH}')
eprint('v hash: ')
eprintln(@VCURRENTHASH)
$if native {
C.exit(1) // TODO: native backtraces
} $else $if exit_after_panic_message ? {
Expand Down Expand Up @@ -155,7 +157,7 @@ pub fn panic(s string) {
pub fn c_error_number_str(errnum int) string {
mut err_msg := ''
$if freestanding {
err_msg = 'error ${errnum}'
err_msg = 'error ' + errnum.str()
} $else {
$if !vinix {
c_msg := C.strerror(errnum)
Expand Down

0 comments on commit 6528efa

Please sign in to comment.