diff --git a/vlib/v/gen/c/str_intp.v b/vlib/v/gen/c/str_intp.v index a3daef03bb..bcc3bf9106 100644 --- a/vlib/v/gen/c/str_intp.v +++ b/vlib/v/gen/c/str_intp.v @@ -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 } } } diff --git a/vlib/v/tests/integer_size_test.v b/vlib/v/tests/integer_size_test.v index 43b1a9c500..6794e11cbc 100644 --- a/vlib/v/tests/integer_size_test.v +++ b/vlib/v/tests/integer_size_test.v @@ -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' + } }