parent
fb75d528eb
commit
30e53c95c7
|
@ -6709,6 +6709,8 @@ fn (mut c Checker) smartcast_if_conds(node ast.Expr, mut scope ast.Scope) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if node is ast.Likely {
|
||||
c.smartcast_if_conds(node.expr, mut scope)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// fixes https://github.com/vlang/v/issues/11485 based on code example by https://github.com/Wertzui123
|
||||
interface IExample {
|
||||
}
|
||||
|
||||
struct Example {
|
||||
value string
|
||||
}
|
||||
|
||||
fn test_if_smartcast_likely() {
|
||||
print_value(Example{ value: 'Hello' })
|
||||
}
|
||||
|
||||
fn print_value(example IExample) {
|
||||
if _likely_(example is Example) {
|
||||
print('Value: ' + example.value)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue