rename none to null
This commit is contained in:
@@ -93,13 +93,13 @@ vif_expression func(old_entries []u8) usize {
|
||||
# --- value loops (milestone 20.5) --------------------------------------------
|
||||
|
||||
# Labeled `for` used as a value: `yield :blk i` exits early with a value, the
|
||||
# trailing `yield none` supplies the value when the loop completes. The `{i,
|
||||
# none}` yields resolve the result to an optional.
|
||||
# trailing `yield null` supplies the value when the loop completes. The `{i,
|
||||
# null}` yields resolve the result to an optional.
|
||||
loop_search func() i32 {
|
||||
# first i in 0..10 whose square exceeds 40 (6*6=36 no, 7*7=49 yes -> 7).
|
||||
idx :: for 0..10 |i| blk: {
|
||||
if (i * i > 40) yield :blk i
|
||||
yield none
|
||||
yield null
|
||||
}
|
||||
if idx |found| {
|
||||
if (found == 7) return 0
|
||||
@@ -108,11 +108,11 @@ loop_search func() i32 {
|
||||
return 2
|
||||
}
|
||||
|
||||
# Same loop, but nothing matches -> the fall-through `yield none` is the result.
|
||||
# Same loop, but nothing matches -> the fall-through `yield null` is the result.
|
||||
loop_none func() i32 {
|
||||
idx :: for 0..10 |i| blk: {
|
||||
if (i > 100) yield :blk i
|
||||
yield none
|
||||
yield null
|
||||
}
|
||||
if idx |found| {
|
||||
_ = found
|
||||
@@ -126,7 +126,7 @@ loop_while func() i32 {
|
||||
n i32 = 0
|
||||
found :: while n < 100 : n += 1 blk: {
|
||||
if (n == 8) yield :blk n
|
||||
yield none
|
||||
yield null
|
||||
}
|
||||
if found |v| {
|
||||
if (v == 8) return 0
|
||||
@@ -164,13 +164,13 @@ orelse_value func(opt ?i32) i32 {
|
||||
return r
|
||||
}
|
||||
|
||||
# Untyped value loop where `none` is yielded (in a labeled yield) before any
|
||||
# Untyped value loop where `null` is yielded (in a labeled yield) before any
|
||||
# concrete value: the element type still resolves to ?<i> from `yield :blk i`.
|
||||
loop_none_first func() i32 {
|
||||
r :: for 0..10 |i| blk: {
|
||||
if (i > 100) yield :blk none
|
||||
if (i > 100) yield :blk null
|
||||
if (i * i > 40) yield :blk i # first concrete yield: i == 7
|
||||
yield none
|
||||
yield null
|
||||
}
|
||||
if r |found| {
|
||||
if (found == 7) return 0
|
||||
@@ -207,10 +207,10 @@ lblock_defer func() i32 {
|
||||
return r # 5, not 999
|
||||
}
|
||||
|
||||
# A labeled block whose `{T, none}` yields resolve the result to an optional.
|
||||
# A labeled block whose `{T, null}` yields resolve the result to an optional.
|
||||
lblock_optional func(present i32) i32 {
|
||||
r :: blk: {
|
||||
if (present == 0) yield :blk none
|
||||
if (present == 0) yield :blk null
|
||||
yield :blk 8
|
||||
}
|
||||
if r |v| {
|
||||
@@ -225,7 +225,7 @@ yield_outer func(target i32) i32 {
|
||||
for 0..3 |col| {
|
||||
if (row * 3 + col == target) yield :outer (row * 10 + col)
|
||||
}
|
||||
yield none
|
||||
yield null
|
||||
}
|
||||
if found |v| {
|
||||
return v
|
||||
@@ -284,11 +284,11 @@ stmt_block_nested func() i32 {
|
||||
return hits
|
||||
}
|
||||
|
||||
# Item B: a `none` yielded before a concrete `yield :blk` that references a block local.
|
||||
# Item B: a `null` yielded before a concrete `yield :blk` that references a block local.
|
||||
lblock_local func() i32 {
|
||||
r :: blk: {
|
||||
val :: 9
|
||||
if (false) yield :blk none
|
||||
if (false) yield :blk null
|
||||
yield :blk val
|
||||
}
|
||||
if r |v| {
|
||||
@@ -321,9 +321,9 @@ main func() i32 {
|
||||
if (vif_return(0) != 11) return 116
|
||||
if (vif_return(1) != 55) return 117
|
||||
if (vif_unwrap(21) != 42) return 118
|
||||
if (vif_unwrap(none) != 99) return 119
|
||||
if (vif_unwrap(null) != 99) return 119
|
||||
if (orelse_value(5) != 5) return 120
|
||||
if (orelse_value(none) != 7) return 121
|
||||
if (orelse_value(null) != 7) return 121
|
||||
if (loop_none_first() != 0) return 122
|
||||
|
||||
if (lblock(0) != 10) return 123
|
||||
|
||||
Reference in New Issue
Block a user