1
0
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:
Delyan Angelov 2021-09-19 05:03:31 +03:00
parent 6799f3ac5c
commit b5d8c53a0c
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
2 changed files with 8 additions and 0 deletions

View File

@ -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 }
}
}

View File

@ -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'
}
}