Skip to content

Commit 44a4975

Browse files
authored
type_resolver: i32 is now $int too (fix #24346) (#24378)
1 parent cbddb8c commit 44a4975

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

vlib/v/tests/comptime/comptime_if_is_test.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,10 @@ fn test_is_or() {
2626
assert g(i8(1)) == 1
2727
assert g(1) == 2
2828
}
29+
30+
fn test_i32_is_int() {
31+
a := i32(33)
32+
$if a !is $int {
33+
assert false
34+
}
35+
}

vlib/v/type_resolver/comptime_resolver.v

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub fn (t &TypeResolver) is_comptime_type(x ast.Type, y ast.ComptimeType) bool {
250250
return x_kind == .string
251251
}
252252
.int {
253-
return x_kind in [.i8, .i16, .int, .i64, .u8, .u16, .u32, .u64, .usize, .isize,
253+
return x_kind in [.i8, .i16, .i32, .int, .i64, .u8, .u16, .u32, .u64, .usize, .isize,
254254
.int_literal]
255255
}
256256
.float {

vlib/x/json2/encoder.v

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ fn (e &Encoder) encode_value_with_level[T](val T, level int, mut buf []u8) ! {
186186
} $else $if T is $enum {
187187
str_int := int(val).str()
188188
unsafe { buf.push_many(str_int.str, str_int.len) }
189-
} $else $if T is $int || T is bool || T is i32 {
190-
// bug? `i32` not in `$int`?
189+
} $else $if T is $int || T is bool {
191190
str_int := val.str()
192191
unsafe { buf.push_many(str_int.str, str_int.len) }
193192
} $else $if T is $float {

0 commit comments

Comments
 (0)