mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
v.gen.c: fix the :X string interpolation format for isize/usize on 64bit systems
This commit is contained in:
parent
6799f3ac5c
commit
b5d8c53a0c
@ -91,6 +91,8 @@ fn (mut g Gen) str_format(node ast.StringInterLiteral, i int) (u64, string) {
|
||||
ast.i64_type { fmt_type = .si_i64 }
|
||||
ast.u64_type { fmt_type = .si_u64 }
|
||||
ast.u32_type { fmt_type = .si_u32 }
|
||||
ast.usize_type { fmt_type = .si_u64 }
|
||||
ast.isize_type { fmt_type = .si_i64 }
|
||||
else { fmt_type = .si_i32 }
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ fn test_usize() {
|
||||
u++
|
||||
assert u == 5
|
||||
assert u.str() == '5'
|
||||
$if x64 {
|
||||
assert '${usize(0x140000000):X}' == '140000000'
|
||||
}
|
||||
}
|
||||
|
||||
fn test_isize() {
|
||||
@ -19,4 +22,7 @@ fn test_isize() {
|
||||
i += 2
|
||||
assert i == -3
|
||||
assert i.str() == '-3'
|
||||
$if x64 {
|
||||
assert '${isize(0x140000000):X}' == '140000000'
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user