v/vlib/v/checker/tests/unsafe_method_as_field.vv

28 lines
263 B
V

struct Foo {
}
fn (f Foo) no_ref() int {
return 1
}
fn (f &Foo) ref() int {
return 1
}
[heap]
struct Bar {
}
fn (f &Bar) ref() int {
return 1
}
fn main() {
f := Foo{}
_ := f.no_ref // no error
_ := f.ref // error
b := Bar{}
_ := b.ref // no error
}