rename none to null

This commit is contained in:
2026-07-21 22:59:51 +02:00
parent 1619ea98a3
commit 402871ef7a
44 changed files with 3771 additions and 3767 deletions
+3 -3
View File
@@ -20,11 +20,11 @@ init func(allocator mem.Allocator) State {
}
hide fail_alloc func(_ ?@mut anyopaque, _ usize, _ usize) ?*mut u8 {
return none
return null
}
hide fail_realloc func(_ ?@mut anyopaque, _ ?*mut u8, _ usize, _ usize, _ usize) ?*mut u8 {
return none
return null
}
hide fail_free func(_ ?@mut anyopaque, _ ?*mut u8, _ usize, _ usize) void {}
@@ -36,7 +36,7 @@ hide fail_vtable mem.AllocatorVTable :: mem.AllocatorVTable {
}
hide fail_allocator mem.Allocator :: mem.Allocator {
context = none,
context = null,
vtable = &fail_vtable,
}
@@ -91,7 +91,7 @@ main func() i32 {
_ = assigned
_ = take_i32(zero())
_ = return_zero()
optional ?u32 = none
optional ?u32 = null
if !same_type(?u32, optional) {
return 8
}
+1 -1
View File
@@ -73,7 +73,7 @@ maybe func(flag bool) ?i32 {
if flag {
return 9
}
return none
return null
}
may_fail func(flag bool) i32 ! Error {
@@ -16,8 +16,8 @@ main func() i32 {
total = total + 99
}
# none -> else branch taken; the binding is not in scope there
b ?i32 = none
# null -> else branch taken; the binding is not in scope there
b ?i32 = null
if b |v| {
total = total + v
} else {
@@ -31,8 +31,8 @@ main func() i32 {
total = total + q^ # +0
}
# optional pointer none -> skipped
z ?@i32 = none
# optional pointer null -> skipped
z ?@i32 = null
if z |_| {
total = total + 1000
}
+6 -6
View File
@@ -38,7 +38,7 @@ hide write_too_much func(_ ?@mut anyopaque, _ io.Handle, bytes []u8) usize ! io.
ok_reader func() io.Reader {
return io.Reader {
context = none,
context = null,
handle = io.Handle {file_desc = 0},
read = read_ok,
}
@@ -46,7 +46,7 @@ ok_reader func() io.Reader {
bad_reader func() io.Reader {
return io.Reader {
context = none,
context = null,
handle = io.Handle {file_desc = 0},
read = read_too_much,
}
@@ -54,7 +54,7 @@ bad_reader func() io.Reader {
eof_reader func() io.Reader {
return io.Reader {
context = none,
context = null,
handle = io.Handle {file_desc = 0},
read = read_eof,
}
@@ -62,7 +62,7 @@ eof_reader func() io.Reader {
short_writer func() io.Writer {
return io.Writer {
context = none,
context = null,
handle = io.Handle {file_desc = 0},
write = write_short,
}
@@ -70,7 +70,7 @@ short_writer func() io.Writer {
none_writer func() io.Writer {
return io.Writer {
context = none,
context = null,
handle = io.Handle {file_desc = 0},
write = write_none,
}
@@ -78,7 +78,7 @@ none_writer func() io.Writer {
bad_writer func() io.Writer {
return io.Writer {
context = none,
context = null,
handle = io.Handle {file_desc = 0},
write = write_too_much,
}
@@ -1,7 +1,7 @@
mem :: import "@std/mem"
raw_allocator_test func() i32 {
resized ?*mut u8 = mem.raw_realloc(mem.c_allocator, none, 0, 4, 1)
resized ?*mut u8 = mem.raw_realloc(mem.c_allocator, null, 0, 4, 1)
if resized |bytes| {
bytes[0] = 10
bytes[1] = 20
@@ -11,9 +11,9 @@ TaskList :: struct {
task_list_init func(allocator mem.Allocator) TaskList {
return TaskList {
ids = none,
priorities = none,
durations = none,
ids = null,
priorities = null,
durations = null,
len = 0,
capacity = 0,
allocator = allocator,
@@ -27,7 +27,7 @@ alloc_i32s func(allocator mem.Allocator, count usize) ?[]mut i32 {
failed = true
yield (&fallback).ptr[..0]
}
if (failed) return none
if (failed) return null
return values
}
@@ -144,9 +144,9 @@ task_list_deinit func(list @mut TaskList) void {
free_i32s(list.allocator, list.ids)
free_i32s(list.allocator, list.priorities)
free_i32s(list.allocator, list.durations)
list.ids = none
list.priorities = none
list.durations = none
list.ids = null
list.priorities = null
list.durations = null
list.len = 0
list.capacity = 0
}
@@ -9,12 +9,12 @@ hide probe_count func(context ?@mut anyopaque) void {
hide probe_alloc func(context ?@mut anyopaque, _ usize, _ usize) ?*mut u8 {
probe_count(context)
return none
return null
}
hide probe_realloc func(context ?@mut anyopaque, _ ?*mut u8, _ usize, _ usize, _ usize) ?*mut u8 {
probe_count(context)
return none
return null
}
hide probe_free func(context ?@mut anyopaque, _ ?*mut u8, _ usize, _ usize) void {
@@ -42,8 +42,8 @@ typed_allocator_test func() i32 {
}
_ = mem.raw_alloc(first_allocator, 1, 1)
_ = mem.raw_realloc(first_allocator, none, 0, 1, 1)
mem.raw_free(first_allocator, none, 0, 1)
_ = mem.raw_realloc(first_allocator, null, 0, 1, 1)
mem.raw_free(first_allocator, null, 0, 1)
_ = mem.raw_alloc(second_allocator, 1, 1)
if (first_calls[0] != 3 or second_calls[0] != 1) return 32
+1 -1
View File
@@ -54,7 +54,7 @@ different Config :: Config {
state = .idle,
values = [21, 21],
pair = Pair {7, false},
maybe = none,
maybe = null,
payload = .empty,
}
+16 -16
View File
@@ -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