v2 / vlib / v / checker / tests / disallow_pointer_arithmetic_err.vv
9 lines · 9 sloc · 237 bytes · 0c8ce3bcb9fd4a2e5bd5f991a5a07da976d780d7
Raw
1fn main() {
2 x := 5
3 p := &x
4 _ := p + p // should be error
5 _ := p * p // should be error
6 _ := p * 2 // should be error
7 _ := p + 5 // OK but only in unsafe block, r is *int
8 _ := p - p // OK even in safe code, but n should be isize
9}
10