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
+19 -19
View File
@@ -228,7 +228,7 @@ Ct_Value_Kind :: enum u8 {
Slice,
Function,
Type,
None,
Null,
Optional_Some,
Fallible,
}
@@ -651,12 +651,12 @@ ct_coerce_value :: proc(state: ^Ct_State, id: Ct_Value_Id, expected: types.Type,
return ct_add_value(state, value), true
}
}
if value.kind == .None {
if value.kind == .Null {
if types.is_optional(expected, store) {
value.type = expected
return ct_add_value(state, value), true
}
return INVALID_CT_VALUE, ct_fail(state, .Not_Comptime, span, "'none' requires an optional context")
return INVALID_CT_VALUE, ct_fail(state, .Not_Comptime, span, "'null' requires an optional context")
}
if types.is_optional(expected, store) {
child := types.child_type(expected, store)
@@ -941,9 +941,9 @@ ct_materialize_value :: proc(
case .Function:
value_expected := expected if types.is_valid(expected) else value.type
return build_function_value(checker, ast.Function_Id(u32(value.index)), span, value_expected)
case .None:
case .Null:
return add_hir_expr(checker, hir.Expr{
kind=.None, span=span, type=value.type,
kind=.Null, span=span, type=value.type,
target=hir.INVALID_REF, left=hir.INVALID_EXPR, right=hir.INVALID_EXPR,
diagnostic=source.INVALID_DIAGNOSTIC,
})
@@ -1154,11 +1154,11 @@ ct_eval_expr :: proc(
return ct_add_value(state, Ct_Value{kind=.Type, type=types.INVALID, index=u64(resolved)}), ct_flow(.Normal), types.is_valid(resolved)
case .Enum_Literal:
return ct_eval_enum_literal(state, expr, expected, depth+1)
case .None:
case .Null:
if !types.is_optional(expected, store) {
return INVALID_CT_VALUE, ct_flow(.Normal), ct_fail(state, .Not_Comptime, expr.span, "'none' requires an optional context")
return INVALID_CT_VALUE, ct_flow(.Normal), ct_fail(state, .Not_Comptime, expr.span, "'null' requires an optional context")
}
return ct_add_value(state, Ct_Value{kind=.None, type=expected}), ct_flow(.Normal), true
return ct_add_value(state, Ct_Value{kind=.Null, type=expected}), ct_flow(.Normal), true
case .Field:
if enum_type, enum_ok := enum_type_from_field_expr(checker, expr, state.pkg, state.file); enum_ok {
member, ok := find_enum_member(checker, enum_type, expr.name)
@@ -1246,7 +1246,7 @@ ct_eval_expr :: proc(
return children[0], ct_flow(.Normal), true
}
}
if v.kind == .None {
if v.kind == .Null {
child := types.child_type(v.type, store)
return ct_eval_expr(state, expr.right, child, depth+1)
}
@@ -1289,7 +1289,7 @@ ct_eval_expr :: proc(
}
left_expr := checker.ast_module.exprs[expr.left]
right_expr := checker.ast_module.exprs[expr.right]
if left_expr.kind == .None && right_expr.kind != .None &&
if left_expr.kind == .Null && right_expr.kind != .Null &&
(expr.kind == .Eq || expr.kind == .Ne) {
right, right_flow, right_ok := ct_eval_expr(state, expr.right, types.INVALID, depth+1)
if !right_ok || right_flow.kind != .Normal {
@@ -2071,8 +2071,8 @@ ct_unwrap_optional :: proc(state: ^Ct_State, id: Ct_Value_Id, span: source.Span)
return children[0], ct_flow(.Normal), true
}
}
if value.kind == .None {
return INVALID_CT_VALUE, ct_flow(.Normal), ct_fail(state, .Not_Comptime, span, "comptime optional unwrap of none")
if value.kind == .Null {
return INVALID_CT_VALUE, ct_flow(.Normal), ct_fail(state, .Not_Comptime, span, "comptime optional unwrap of null")
}
return INVALID_CT_VALUE, ct_flow(.Normal), ct_fail(state, .Not_Comptime, span, "postfix '?' requires an optional")
}
@@ -2132,13 +2132,13 @@ ct_eval_binary :: proc(state: ^Ct_State, op: ast.Expr_Kind, left_id, right_id: C
left := state.values[left_id]
right := state.values[right_id]
is_compare := op == .Eq || op == .Ne || op == .Lt || op == .Le || op == .Gt || op == .Ge
if left.kind == .None || right.kind == .None {
if left.kind == .Null || right.kind == .Null {
if (op != .Eq && op != .Ne) ||
!types.is_optional(left.type, &state.checker.module.types) ||
!types.equal(left.type, right.type) {
return INVALID_CT_VALUE, ct_flow(.Normal), ct_fail(state, .Not_Comptime, span, "'none' only supports '==' and '!=' with an optional value")
return INVALID_CT_VALUE, ct_flow(.Normal), ct_fail(state, .Not_Comptime, span, "'null' only supports '==' and '!=' with an optional value")
}
equal := left.kind == .None && right.kind == .None
equal := left.kind == .Null && right.kind == .Null
if op == .Ne {
equal = !equal
}
@@ -2781,7 +2781,7 @@ ct_typeinfo_value :: proc(state: ^Ct_State, target: types.Type, span: source.Spa
kind=.Array, type=fields_type, start=fields_start, count=u32(len(field_values)),
})
name_optional_type := types.optional(store, types.slice(store, types.U8, false))
record_name := ct_add_value(state, Ct_Value{kind=.None, type=name_optional_type})
record_name := ct_add_value(state, Ct_Value{kind=.Null, type=name_optional_type})
if item.name != 0 {
name_value := ct_reflection_string(state, symbol_text(checker, symbol.Id(item.name)))
name_start := u32(len(state.children))
@@ -3053,7 +3053,7 @@ ct_struct_type :: proc(
)
}
default := state.values[value]
if default.kind == .None {
if default.kind == .Null {
continue
}
children := ct_child_slice(state, default)
@@ -3616,7 +3616,7 @@ ct_write_comptime_key :: proc(state: ^Ct_State, id: Ct_Value_Id, builder: ^strin
}
strings.write_string(builder, "];")
return true
case .None:
case .Null:
strings.write_string(builder, "n;")
return true
case .Optional_Some:
@@ -4156,7 +4156,7 @@ ct_exec_if :: proc(state: ^Ct_State, statement: ast.Stmt, yield_returns: bool, d
return flow, ok
}
v := state.values[value]
if v.kind == .None {
if v.kind == .Null {
matched = false
break
}