checker: forbid multiple pointer yields (#11105)
parent
eed8c4671f
commit
a64b191ce5
|
@ -7117,6 +7117,13 @@ pub fn (mut c Checker) prefix_expr(mut node ast.PrefixExpr) ast.Type {
|
|||
right_type := c.expr(node.right)
|
||||
c.inside_ref_lit = old_inside_ref_lit
|
||||
node.right_type = right_type
|
||||
if node.op == .amp {
|
||||
if mut node.right is ast.PrefixExpr {
|
||||
if node.right.op == .amp {
|
||||
c.error('unexpected `&`, expecting expression', node.right.pos)
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: testing ref/deref strategy
|
||||
if node.op == .amp && !right_type.is_ptr() {
|
||||
mut expr := node.right
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
vlib/v/checker/tests/multiple_pointer_yield_err.vv:9:8: error: unexpected `&`, expecting expression
|
||||
7 | fn main() {
|
||||
8 | f := Fail{}
|
||||
9 | foo(&&&f)
|
||||
| ^
|
||||
10 | }
|
|
@ -0,0 +1,10 @@
|
|||
struct Fail {
|
||||
name string
|
||||
}
|
||||
|
||||
fn foo(bar &&&Fail) {}
|
||||
|
||||
fn main() {
|
||||
f := Fail{}
|
||||
foo(&&&f)
|
||||
}
|
Loading…
Reference in New Issue