mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
vfmt: change all '$expr' to '${expr}' (#16428)
This commit is contained in:
@@ -35,11 +35,11 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
|
||||
bare_panic(s)
|
||||
} $else {
|
||||
eprintln('================ V panic ================')
|
||||
eprintln(' module: $mod')
|
||||
eprintln(' module: ${mod}')
|
||||
eprintln(' function: ${fn_name}()')
|
||||
eprintln(' message: $s')
|
||||
eprintln(' file: $file:$line_no')
|
||||
eprintln(' v hash: $vcommithash()')
|
||||
eprintln(' message: ${s}')
|
||||
eprintln(' file: ${file}:${line_no}')
|
||||
eprintln(' v hash: ${vcommithash()}')
|
||||
eprintln('=========================================')
|
||||
$if exit_after_panic_message ? {
|
||||
C.exit(1)
|
||||
@@ -72,14 +72,14 @@ fn panic_debug(line_no int, file string, mod string, fn_name string, s string) {
|
||||
// It ends the program with a panic.
|
||||
[noreturn]
|
||||
pub fn panic_optional_not_set(s string) {
|
||||
panic('optional not set ($s)')
|
||||
panic('optional not set (${s})')
|
||||
}
|
||||
|
||||
// panic_optional_not_set is called by V, when you use result error propagation in your main function
|
||||
// It ends the program with a panic.
|
||||
[noreturn]
|
||||
pub fn panic_result_not_set(s string) {
|
||||
panic('result not set ($s)')
|
||||
panic('result not set (${s})')
|
||||
}
|
||||
|
||||
// panic prints a nice error message, then exits the process with exit code of 1.
|
||||
@@ -91,7 +91,7 @@ pub fn panic(s string) {
|
||||
} $else {
|
||||
eprint('V panic: ')
|
||||
eprintln(s)
|
||||
eprintln('v hash: $vcommithash()')
|
||||
eprintln('v hash: ${vcommithash()}')
|
||||
$if exit_after_panic_message ? {
|
||||
C.exit(1)
|
||||
} $else $if no_backtrace ? {
|
||||
@@ -123,7 +123,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}'
|
||||
} $else {
|
||||
$if !vinix {
|
||||
c_msg := C.strerror(errnum)
|
||||
@@ -297,7 +297,7 @@ __global total_m = i64(0)
|
||||
[unsafe]
|
||||
pub fn malloc(n isize) &u8 {
|
||||
if n <= 0 {
|
||||
panic('malloc($n <= 0)')
|
||||
panic('malloc(${n} <= 0)')
|
||||
}
|
||||
$if vplayground ? {
|
||||
if n > 10000 {
|
||||
@@ -327,7 +327,7 @@ pub fn malloc(n isize) &u8 {
|
||||
res = unsafe { C.malloc(n) }
|
||||
}
|
||||
if res == 0 {
|
||||
panic('malloc($n) failed')
|
||||
panic('malloc(${n}) failed')
|
||||
}
|
||||
$if debug_malloc ? {
|
||||
// Fill in the memory with something != 0 i.e. `M`, so it is easier to spot
|
||||
@@ -340,7 +340,7 @@ pub fn malloc(n isize) &u8 {
|
||||
[unsafe]
|
||||
pub fn malloc_noscan(n isize) &u8 {
|
||||
if n <= 0 {
|
||||
panic('malloc_noscan($n <= 0)')
|
||||
panic('malloc_noscan(${n} <= 0)')
|
||||
}
|
||||
$if vplayground ? {
|
||||
if n > 10000 {
|
||||
@@ -374,7 +374,7 @@ pub fn malloc_noscan(n isize) &u8 {
|
||||
res = unsafe { C.malloc(n) }
|
||||
}
|
||||
if res == 0 {
|
||||
panic('malloc_noscan($n) failed')
|
||||
panic('malloc_noscan(${n}) failed')
|
||||
}
|
||||
$if debug_malloc ? {
|
||||
// Fill in the memory with something != 0 i.e. `M`, so it is easier to spot
|
||||
@@ -389,7 +389,7 @@ pub fn malloc_noscan(n isize) &u8 {
|
||||
[unsafe]
|
||||
pub fn malloc_uncollectable(n isize) &u8 {
|
||||
if n <= 0 {
|
||||
panic('malloc_uncollectable($n <= 0)')
|
||||
panic('malloc_uncollectable(${n} <= 0)')
|
||||
}
|
||||
$if vplayground ? {
|
||||
if n > 10000 {
|
||||
@@ -417,7 +417,7 @@ pub fn malloc_uncollectable(n isize) &u8 {
|
||||
res = unsafe { C.malloc(n) }
|
||||
}
|
||||
if res == 0 {
|
||||
panic('malloc_uncollectable($n) failed')
|
||||
panic('malloc_uncollectable(${n}) failed')
|
||||
}
|
||||
$if debug_malloc ? {
|
||||
// Fill in the memory with something != 0 i.e. `M`, so it is easier to spot
|
||||
@@ -449,7 +449,7 @@ pub fn v_realloc(b &u8, n isize) &u8 {
|
||||
new_ptr = unsafe { C.realloc(b, n) }
|
||||
}
|
||||
if new_ptr == 0 {
|
||||
panic('realloc($n) failed')
|
||||
panic('realloc(${n}) failed')
|
||||
}
|
||||
return new_ptr
|
||||
}
|
||||
@@ -495,7 +495,7 @@ pub fn realloc_data(old_data &u8, old_size int, new_size int) &u8 {
|
||||
nptr = unsafe { C.realloc(old_data, new_size) }
|
||||
}
|
||||
if nptr == 0 {
|
||||
panic('realloc_data($old_data, $old_size, $new_size) failed')
|
||||
panic('realloc_data(${old_data}, ${old_size}, ${new_size}) failed')
|
||||
}
|
||||
return nptr
|
||||
}
|
||||
@@ -505,7 +505,7 @@ pub fn realloc_data(old_data &u8, old_size int, new_size int) &u8 {
|
||||
// Unlike `v_calloc` vcalloc checks for negative values given in `n`.
|
||||
pub fn vcalloc(n isize) &u8 {
|
||||
if n < 0 {
|
||||
panic('calloc($n < 0)')
|
||||
panic('calloc(${n} < 0)')
|
||||
} else if n == 0 {
|
||||
return &u8(0)
|
||||
}
|
||||
@@ -538,7 +538,7 @@ pub fn vcalloc_noscan(n isize) &u8 {
|
||||
}
|
||||
}
|
||||
if n < 0 {
|
||||
panic('calloc_noscan($n < 0)')
|
||||
panic('calloc_noscan(${n} < 0)')
|
||||
}
|
||||
return $if gcboehm_opt ? {
|
||||
unsafe { &u8(C.memset(C.GC_MALLOC_ATOMIC(n), 0, n)) }
|
||||
@@ -613,7 +613,7 @@ pub fn memdup_uncollectable(src voidptr, sz int) voidptr {
|
||||
fn v_fixed_index(i int, len int) int {
|
||||
$if !no_bounds_checking {
|
||||
if i < 0 || i >= len {
|
||||
s := 'fixed array index out of range (index: $i, len: $len)'
|
||||
s := 'fixed array index out of range (index: ${i}, len: ${len})'
|
||||
panic(s)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user