1
0
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:
れもん
2019-12-22 07:44:16 +09:00
committed by Alexander Medvednikov
parent b76227b781
commit 28ecfb231d
14 changed files with 98 additions and 48 deletions

View File

@ -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
}