mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
17
vlib/v/tests/if_smartcast_likely_test.v
Normal file
17
vlib/v/tests/if_smartcast_likely_test.v
Normal file
@ -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
Block a user