mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: map[string]pointer, ?pointer, fix []pointer
This commit is contained in:

committed by
Alexander Medvednikov

parent
b76227b781
commit
28ecfb231d
@ -124,3 +124,23 @@ fn test_opt_field() {
|
||||
val := t.opt or { return }
|
||||
assert val == 5
|
||||
}
|
||||
|
||||
fn opt_ptr(a &int) ?&int {
|
||||
if isnil(a) {
|
||||
return none
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
fn test_opt_ptr() {
|
||||
a := 3
|
||||
r1 := opt_ptr(&a) or {
|
||||
&int(0)
|
||||
}
|
||||
assert r1 == &a
|
||||
r2 := opt_ptr(&int(0)) or {
|
||||
return
|
||||
}
|
||||
println('`$r2` should be none')
|
||||
assert false
|
||||
}
|
||||
|
Reference in New Issue
Block a user