checker: fix cast to byte in comptime if (#13036)
parent
89ac2a37c5
commit
ba9aad1d92
|
@ -2629,7 +2629,7 @@ pub fn (mut c Checker) cast_expr(mut node ast.CastExpr) ast.Type {
|
|||
// node.typ: `Outside`
|
||||
node.expr_type = c.expr(node.expr) // type to be casted
|
||||
|
||||
mut from_type := node.expr_type
|
||||
mut from_type := c.unwrap_generic(node.expr_type)
|
||||
from_sym := c.table.sym(from_type)
|
||||
final_from_sym := c.table.final_sym(from_type)
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
fn test_cast_in_comptime_if() {
|
||||
generic_bool(true)
|
||||
}
|
||||
|
||||
fn generic_bool<T>(val T) {
|
||||
$if T is bool {
|
||||
println(byte(val))
|
||||
assert byte(val) == 1
|
||||
|
||||
println(i8(val))
|
||||
assert i8(val) == 1
|
||||
|
||||
println(i16(val))
|
||||
assert i16(val) == 1
|
||||
} $else {
|
||||
assert false
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue