rename none to null
This commit is contained in:
+34
-32
@@ -206,7 +206,7 @@ parser_applies_bitwise_precedence_and_preserves_capture_and_deref_pipes :: proc(
|
||||
value i32 = 1
|
||||
pointer *i32 = &value
|
||||
_ = pointer^ & 1
|
||||
if (none | none) |captured| { _ = captured }
|
||||
if (null | null) |captured| { _ = captured }
|
||||
}
|
||||
`
|
||||
source_file := source.Source{path="test.bro", text=text}
|
||||
@@ -346,7 +346,7 @@ bitwise_checker_rejects_invalid_operands_and_known_overshifts :: proc(t: ^testin
|
||||
text := `D :: distinct u8
|
||||
E :: enum { one }
|
||||
main func() void {
|
||||
p *u8 = none
|
||||
p *u8 = null
|
||||
d D = D(1)
|
||||
e E = .one
|
||||
signed_count i8 = 1
|
||||
@@ -1380,7 +1380,7 @@ main func() void {
|
||||
testing.expect(t, strings.contains(llvm_text, "declare i32 @exact(i32)"))
|
||||
testing.expect(t, strings.contains(llvm_text, "@bro.str.0 = private unnamed_addr constant [6 x i8] c\"hello\\00\""))
|
||||
testing.expect(t, strings.contains(llvm_text, "getelementptr [3 x i8]"))
|
||||
testing.expect(t, strings.contains(llvm_text, "attempted to unwrap none"))
|
||||
testing.expect(t, strings.contains(llvm_text, "attempted to unwrap null"))
|
||||
testing.expect(t, strings.contains(llvm_text, "orelse_fallback"))
|
||||
testing.expect(t, strings.contains(llvm_text, "orelse_some"))
|
||||
}
|
||||
@@ -2109,7 +2109,7 @@ main func() void {
|
||||
p^ = 2
|
||||
}
|
||||
|
||||
handle ?@mut Handle = none
|
||||
handle ?@mut Handle = null
|
||||
use_handle(handle)
|
||||
}
|
||||
`
|
||||
@@ -2147,7 +2147,7 @@ main func() void {
|
||||
anyopaque_by_value_and_invalid_ptrcasts_are_rejected :: proc(t: ^testing.T) {
|
||||
text := `Callback :: alias c_func() void
|
||||
main func() void {
|
||||
raw ?*mut anyopaque = none
|
||||
raw ?*mut anyopaque = null
|
||||
value anyopaque = undefined
|
||||
_ = ptrcast!(void, raw)
|
||||
_ = ptrcast!(anyopaque, raw)
|
||||
@@ -5685,7 +5685,7 @@ yield_compiles_and_runs :: proc(t: ^testing.T) {
|
||||
state := run_executable(output)
|
||||
// Value blocks, value if-statements (incl. `return` branches and unwrap-`if`),
|
||||
// `orelse`, value loops, labeled value blocks (`blk: { … yield :blk v }`, incl.
|
||||
// defer-capture, `{T,none}` → optional, and `none` before a concrete yield that uses a
|
||||
// defer-capture, `{T,null}` → optional, and `null` before a concrete yield that uses a
|
||||
// block local), outer-loop control (`yield :outer v` / `break :outer`), and labeled
|
||||
// block statements exited via `break :blk` together produce 42.
|
||||
testing.expect_value(t, state.exit_code, 42)
|
||||
@@ -5706,7 +5706,7 @@ value_loop_label_does_not_shadow_own_yield_target :: proc(t: ^testing.T) {
|
||||
text := `main func() i32 {
|
||||
idx :: for 0..10 |i| hit: {
|
||||
if (i == 3) yield :hit i
|
||||
yield none
|
||||
yield null
|
||||
}
|
||||
if idx |found| {
|
||||
if (found == 3) return 0
|
||||
@@ -9247,7 +9247,7 @@ apply func($callback func() i32) i32 { return callback() }
|
||||
main func() i32 {
|
||||
box top.Box(i32) :: top.Box(i32) { value = 2 }
|
||||
point top.Point :: top.Point { value = 3 }
|
||||
maybe facade.MaybePoint :: none
|
||||
maybe facade.MaybePoint :: null
|
||||
scalar facade.Scalar :: 5
|
||||
top.counter = 7
|
||||
if box.value != 2 or point.value != 3 { return 1 }
|
||||
@@ -14084,15 +14084,15 @@ TokenKind :: enum(u8) {
|
||||
}
|
||||
Simple :: enum { first, second }
|
||||
|
||||
Names :: alias meta.EnumFieldStruct(TokenKind, ?[]u8, some!(none))
|
||||
Names :: alias meta.EnumFieldStruct(TokenKind, ?[]u8, some!(null))
|
||||
Flags :: alias meta.EnumFieldStruct(Simple, bool, false)
|
||||
Direct :: alias struct_type!(.auto, {"x", "name"}, {i32, []u8}, {none, "bro"})
|
||||
CPoint :: alias struct_type!(.c, {"x"}, {c_int}, {none})
|
||||
Direct :: alias struct_type!(.auto, {"x", "name"}, {i32, []u8}, {null, "bro"})
|
||||
CPoint :: alias struct_type!(.c, {"x"}, {c_int}, {null})
|
||||
ArrayInput :: alias struct_type!(.auto, ["value"], [i32], [7])
|
||||
Empty :: alias struct_type!(.auto, {}, {}, {})
|
||||
direct_position struct_type!(.auto, {"value"}, {i32}, {none}) = {value = 5}
|
||||
direct_position struct_type!(.auto, {"value"}, {i32}, {null}) = {value = 5}
|
||||
|
||||
make_direct func() struct_type!(.auto, {"value"}, {i32}, {none}) {
|
||||
make_direct func() struct_type!(.auto, {"value"}, {i32}, {null}) {
|
||||
return {value = 6}
|
||||
}
|
||||
|
||||
@@ -14108,8 +14108,9 @@ Generated func($T type) type {
|
||||
|
||||
GeneratedInt :: alias Generated(i32)
|
||||
ordered Names = {}
|
||||
static_none ?i32 :: none
|
||||
static_none ?i32 :: null
|
||||
static_some ?i32 :: 1
|
||||
none :: 41
|
||||
|
||||
Map func($E, $V type) type {
|
||||
match typeinfo!(E) {
|
||||
@@ -14121,7 +14122,7 @@ Map func($E, $V type) type {
|
||||
}
|
||||
}
|
||||
|
||||
init func($E, $V type, values meta.EnumFieldStruct(E, ?V, some!(none))) Map(E, V) {
|
||||
init func($E, $V type, values meta.EnumFieldStruct(E, ?V, some!(null))) Map(E, V) {
|
||||
map Map(E, V) = undefined
|
||||
match typeinfo!(E) {
|
||||
.enum |info|: expand for info.fields |field, index| {
|
||||
@@ -14141,7 +14142,7 @@ get func($E, $V type, map @Map(E, V), key E) ?V {
|
||||
.enum |info|: expand for info.fields |field, index| {
|
||||
if key == field!(E, field.name) {
|
||||
if map.present[index] { return map.values[index] }
|
||||
return none
|
||||
return null
|
||||
}
|
||||
}
|
||||
else: compile_error!("EnumMap key must be an enum")
|
||||
@@ -14150,8 +14151,9 @@ get func($E, $V type, map @Map(E, V), key E) ?V {
|
||||
|
||||
main func() i32 {
|
||||
_ = ordered
|
||||
if !$(static_none == none) or !$(none == static_none) or
|
||||
$(static_some == none) or $(none == static_some) { return 23 }
|
||||
if none != 41 { return 24 }
|
||||
if !$(static_none == null) or !$(null == static_none) or
|
||||
$(static_some == null) or $(null == static_some) { return 23 }
|
||||
inferred :: {x = 40, name = "bro"}
|
||||
if inferred.x != 40 or inferred.name.len != 3 { return 1 }
|
||||
direct Direct = {x = 7}
|
||||
@@ -14167,7 +14169,7 @@ main func() i32 {
|
||||
if direct_position.value != 5 or make_direct().value != 6 { return 17 }
|
||||
c_point CPoint = {x = 9}
|
||||
if c_point.x != 9 { return 12 }
|
||||
nested ??i32 = some!(none)
|
||||
nested ??i32 = some!(null)
|
||||
if nested |inner| {
|
||||
if inner |_| { return 13 }
|
||||
} else { return 14 }
|
||||
@@ -14196,14 +14198,14 @@ main func() i32 {
|
||||
if !map.present[0] or !map.present[1] or map.present[2] { return 9 }
|
||||
if map.values[0].len != 10 or map.values[1].len != 7 { return 18 }
|
||||
ident :: get(TokenKind, []u8, &map, TokenKind.ident)
|
||||
if ident == none or none == ident { return 19 }
|
||||
if ident == null or null == ident { return 19 }
|
||||
if ident |value| {
|
||||
if value.len != 10 { return 19 }
|
||||
} else { return 20 }
|
||||
eof :: get(TokenKind, []u8, &map, TokenKind.eof)
|
||||
if eof != none or none != eof { return 21 }
|
||||
if eof != null or null != eof { return 21 }
|
||||
location testing.SourceLocation = {file = "test.bro", line = 1, column = 1}
|
||||
testing.expect_equal(none, eof, location) catch |_| { return 24 }
|
||||
testing.expect_equal(null, eof, location) catch |_| { return 24 }
|
||||
testing.expect_equal(ident, ident, location) catch |_| { return 25 }
|
||||
if eof |_| { return 22 }
|
||||
return 0
|
||||
@@ -14275,18 +14277,18 @@ anonymous_records_and_struct_type_report_targeted_errors :: proc(t: ^testing.T)
|
||||
main_path := "/tmp/brolang-test-bad-struct-type/main.bro"
|
||||
text := `meta :: import "@std/meta"
|
||||
E :: enum { value }
|
||||
Fields :: alias struct_type!(.auto, {"value"}, {i32}, {none})
|
||||
RequiredEnum :: alias meta.EnumFieldStruct(E, i32, none)
|
||||
NotEnum :: alias meta.EnumFieldStruct(i32, i32, none)
|
||||
BadField :: alias struct_type!(.auto, {"value"}, {void}, {none})
|
||||
BadComptimeField :: alias struct_type!(.auto, {"T"}, {type}, {none})
|
||||
Fields :: alias struct_type!(.auto, {"value"}, {i32}, {null})
|
||||
RequiredEnum :: alias meta.EnumFieldStruct(E, i32, null)
|
||||
NotEnum :: alias meta.EnumFieldStruct(i32, i32, null)
|
||||
BadField :: alias struct_type!(.auto, {"value"}, {void}, {null})
|
||||
BadComptimeField :: alias struct_type!(.auto, {"T"}, {type}, {null})
|
||||
BadDefault :: alias struct_type!(.auto, {"value"}, {i32}, {"no"})
|
||||
UnstableDefault :: alias struct_type!(.auto, {"value"}, {i32}, {undefined})
|
||||
BadLengths :: alias struct_type!(.auto, {"one", "two"}, {i32}, {none})
|
||||
BadNames :: alias struct_type!(.auto, {"not-valid"}, {i32}, {none})
|
||||
DuplicateNames :: alias struct_type!(.auto, {"same", "same"}, {i32, i32}, {none, none})
|
||||
BadLayout :: alias struct_type!(.packed, {"value"}, {i32}, {none})
|
||||
BadC :: alias struct_type!(.c, {"value"}, {[]u8}, {none})
|
||||
BadLengths :: alias struct_type!(.auto, {"one", "two"}, {i32}, {null})
|
||||
BadNames :: alias struct_type!(.auto, {"not-valid"}, {i32}, {null})
|
||||
DuplicateNames :: alias struct_type!(.auto, {"same", "same"}, {i32, i32}, {null, null})
|
||||
BadLayout :: alias struct_type!(.packed, {"value"}, {i32}, {null})
|
||||
BadC :: alias struct_type!(.c, {"value"}, {[]u8}, {null})
|
||||
EmptyC :: alias struct_type!(.c, {}, {}, {})
|
||||
unknown Fields = {missing = 1}
|
||||
duplicate Fields = {value = 1, value = 2}
|
||||
|
||||
Reference in New Issue
Block a user