mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
checker: fix comptime if generic value shift (#15471)
This commit is contained in:
parent
46f32fc10c
commit
6062708c60
@ -401,7 +401,9 @@ pub fn (mut c Checker) check_matching_function_symbols(got_type_sym &ast.TypeSym
|
||||
return true
|
||||
}
|
||||
|
||||
fn (mut c Checker) check_shift(mut node ast.InfixExpr, left_type ast.Type, right_type ast.Type) ast.Type {
|
||||
fn (mut c Checker) check_shift(mut node ast.InfixExpr, left_type_ ast.Type, right_type_ ast.Type) ast.Type {
|
||||
left_type := c.unwrap_generic(left_type_)
|
||||
right_type := c.unwrap_generic(right_type_)
|
||||
if !left_type.is_int() {
|
||||
left_sym := c.table.sym(left_type)
|
||||
// maybe it's an int alias? TODO move this to is_int()?
|
||||
|
13
vlib/v/tests/comptime_if_generic_shift_test.v
Normal file
13
vlib/v/tests/comptime_if_generic_shift_test.v
Normal file
@ -0,0 +1,13 @@
|
||||
fn generic<T>(val T) T {
|
||||
$if T is u64 {
|
||||
println(val << 1)
|
||||
return val << 1
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
fn test_comptime_if_generic_shift() {
|
||||
ret := generic(u64(2))
|
||||
println(ret)
|
||||
assert ret == 4
|
||||
}
|
Loading…
Reference in New Issue
Block a user