aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-05-22 12:53:29 +0100
committergingerBill <bill@gingerbill.org>2023-05-22 12:53:29 +0100
commit8bf32ac697ea21ff3b37e5b31fe0fc10e700c9a4 (patch)
tree77e96ea43b5faf78d81ca1d8158db59fe3e24add /src
parent540f724b1f57d0d5a40b65a59f6ee82e070c6ee5 (diff)
Minor change to handling of propagation of errors with `---` as a value
Diffstat (limited to 'src')
-rw-r--r--src/check_decl.cpp9
-rw-r--r--src/check_expr.cpp45
-rw-r--r--src/check_type.cpp6
-rw-r--r--src/checker.cpp4
-rw-r--r--src/llvm_backend.cpp10
-rw-r--r--src/llvm_backend_const.cpp2
-rw-r--r--src/llvm_backend_debug.cpp2
-rw-r--r--src/llvm_backend_expr.cpp16
-rw-r--r--src/llvm_backend_general.cpp4
-rw-r--r--src/llvm_backend_proc.cpp8
-rw-r--r--src/parser.cpp14
-rw-r--r--src/parser.hpp2
-rw-r--r--src/parser_pos.cpp4
-rw-r--r--src/tokenizer.cpp6
-rw-r--r--src/types.cpp19
15 files changed, 69 insertions, 82 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index b16215571..84b0d39d8 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -70,13 +70,12 @@ gb_internal Type *check_init_variable(CheckerContext *ctx, Entity *e, Operand *o
// NOTE(bill): Use the type of the operand
Type *t = operand->type;
if (is_type_untyped(t)) {
- if (t == t_invalid || is_type_untyped_nil(t)) {
- error(e->token, "Invalid use of untyped nil in %.*s", LIT(context_name));
+ if (is_type_untyped_uninit(t)) {
+ error(e->token, "Invalid use of --- in %.*s", LIT(context_name));
e->type = t_invalid;
return nullptr;
- }
- if (t == t_invalid || is_type_untyped_undef(t)) {
- error(e->token, "Invalid use of --- in %.*s", LIT(context_name));
+ } else if (t == t_invalid || is_type_untyped_nil(t)) {
+ error(e->token, "Invalid use of untyped nil in %.*s", LIT(context_name));
e->type = t_invalid;
return nullptr;
}
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 20a690e1e..830b5315d 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -646,11 +646,8 @@ gb_internal i64 check_distance_between_types(CheckerContext *c, Operand *operand
Type *src = base_type(s);
Type *dst = base_type(type);
- if (is_type_untyped_undef(src)) {
- if (type_has_undef(dst)) {
- return 1;
- }
- return -1;
+ if (is_type_untyped_uninit(src)) {
+ return 1;
}
if (is_type_untyped_nil(src)) {
@@ -993,13 +990,13 @@ gb_internal void check_assignment(CheckerContext *c, Operand *operand, Type *typ
if (is_type_untyped(operand->type)) {
Type *target_type = type;
if (type == nullptr || is_type_any(type)) {
- if (type == nullptr && is_type_untyped_nil(operand->type)) {
- error(operand->expr, "Use of untyped nil in %.*s", LIT(context_name));
+ if (type == nullptr && is_type_untyped_uninit(operand->type)) {
+ error(operand->expr, "Use of --- in %.*s", LIT(context_name));
operand->mode = Addressing_Invalid;
return;
}
- if (type == nullptr && is_type_untyped_undef(operand->type)) {
- error(operand->expr, "Use of --- in %.*s", LIT(context_name));
+ if (type == nullptr && is_type_untyped_nil(operand->type)) {
+ error(operand->expr, "Use of untyped nil in %.*s", LIT(context_name));
operand->mode = Addressing_Invalid;
return;
}
@@ -3969,7 +3966,7 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar
case Type_Union:
- if (!is_operand_nil(*operand) && !is_operand_undef(*operand)) {
+ if (!is_operand_nil(*operand) && !is_operand_uninit(*operand)) {
TEMPORARY_ALLOCATOR_GUARD();
isize count = t->Union.variants.count;
@@ -4036,8 +4033,8 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar
error_line("\n\n");
return;
- } else if (is_type_untyped_undef(operand->type) && type_has_undef(target_type)) {
- target_type = t_untyped_undef;
+ } else if (is_type_untyped_uninit(operand->type)) {
+ target_type = t_untyped_uninit;
} else if (!is_type_untyped_nil(operand->type) || !type_has_nil(target_type)) {
begin_error_block();
defer (end_error_block());
@@ -4070,8 +4067,8 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar
default:
- if (is_type_untyped_undef(operand->type) && type_has_undef(target_type)) {
- target_type = t_untyped_undef;
+ if (is_type_untyped_uninit(operand->type)) {
+ target_type = t_untyped_uninit;
} else if (is_type_untyped_nil(operand->type) && type_has_nil(target_type)) {
target_type = t_untyped_nil;
} else {
@@ -4083,8 +4080,8 @@ gb_internal void convert_to_typed(CheckerContext *c, Operand *operand, Type *tar
}
if (is_type_any(target_type) && is_type_untyped(operand->type)) {
- if (is_type_untyped_nil(operand->type) && is_type_untyped_undef(operand->type)) {
-
+ if (is_type_untyped_nil(operand->type) && is_type_untyped_uninit(operand->type)) {
+
} else {
target_type = default_type(operand->type);
}
@@ -5197,9 +5194,9 @@ gb_internal bool check_unpack_arguments(CheckerContext *ctx, Entity **lhs, isize
}
Ast *rhs_expr = unparen_expr(rhs[i]);
- if (allow_undef && rhs_expr != nullptr && rhs_expr->kind == Ast_Undef) {
+ if (allow_undef && rhs_expr != nullptr && rhs_expr->kind == Ast_Uninit) {
// NOTE(bill): Just handle this very specific logic here
- o.type = t_untyped_undef;
+ o.type = t_untyped_uninit;
o.mode = Addressing_Value;
o.expr = rhs[i];
add_type_and_value(c, rhs[i], o.mode, o.type, o.value);
@@ -7167,11 +7164,11 @@ gb_internal bool check_set_index_data(Operand *o, Type *t, bool indirection, i64
}
gb_internal bool ternary_compare_types(Type *x, Type *y) {
- if (is_type_untyped_undef(x) && type_has_undef(y)) {
+ if (is_type_untyped_uninit(x)) {
return true;
} else if (is_type_untyped_nil(x) && type_has_nil(y)) {
return true;
- } else if (is_type_untyped_undef(y) && type_has_undef(x)) {
+ } else if (is_type_untyped_uninit(y)) {
return true;
} else if (is_type_untyped_nil(y) && type_has_nil(x)) {
return true;
@@ -7708,7 +7705,7 @@ gb_internal ExprKind check_ternary_if_expr(CheckerContext *c, Operand *o, Ast *n
}
o->type = x.type;
- if (is_type_untyped_nil(o->type) || is_type_untyped_undef(o->type)) {
+ if (is_type_untyped_nil(o->type) || is_type_untyped_uninit(o->type)) {
o->type = y.type;
}
@@ -9601,9 +9598,9 @@ gb_internal ExprKind check_expr_base_internal(CheckerContext *c, Operand *o, Ast
check_ident(c, o, node, nullptr, type_hint, false);
case_end;
- case_ast_node(u, Undef, node);
+ case_ast_node(u, Uninit, node);
o->mode = Addressing_Value;
- o->type = t_untyped_undef;
+ o->type = t_untyped_uninit;
error(node, "Use of --- outside of variable declaration");
case_end;
@@ -10167,7 +10164,7 @@ gb_internal gbString write_expr_to_string(gbString str, Ast *node, bool shorthan
str = string_append_string(str, bd->name.string);
case_end;
- case_ast_node(ud, Undef, node);
+ case_ast_node(ud, Uninit, node);
str = gb_string_appendc(str, "---");
case_end;
diff --git a/src/check_type.cpp b/src/check_type.cpp
index dfe774f6b..bbfc25a12 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -135,7 +135,7 @@ gb_internal void check_struct_fields(CheckerContext *ctx, Ast *node, Slice<Entit
type = t_invalid;
}
if (is_type_untyped(type)) {
- if (is_type_untyped_undef(type)) {
+ if (is_type_untyped_uninit(type)) {
error(params[i], "Cannot determine parameter type from ---");
} else {
error(params[i], "Cannot determine parameter type from a nil");
@@ -473,7 +473,7 @@ gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *poly
type = t_invalid;
}
if (is_type_untyped(type)) {
- if (is_type_untyped_undef(type)) {
+ if (is_type_untyped_uninit(type)) {
error(params[i], "Cannot determine parameter type from ---");
} else {
error(params[i], "Cannot determine parameter type from a nil");
@@ -1528,7 +1528,7 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
type = t_invalid;
}
if (is_type_untyped(type)) {
- if (is_type_untyped_undef(type)) {
+ if (is_type_untyped_uninit(type)) {
error(param, "Cannot determine parameter type from ---");
} else {
error(param, "Cannot determine parameter type from a nil");
diff --git a/src/checker.cpp b/src/checker.cpp
index a6768d495..c22ad1645 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -27,8 +27,8 @@ gb_internal bool is_operand_value(Operand o) {
gb_internal bool is_operand_nil(Operand o) {
return o.mode == Addressing_Value && o.type == t_untyped_nil;
}
-gb_internal bool is_operand_undef(Operand o) {
- return o.mode == Addressing_Value && o.type == t_untyped_undef;
+gb_internal bool is_operand_uninit(Operand o) {
+ return o.mode == Addressing_Value && o.type == t_untyped_uninit;
}
gb_internal bool check_rtti_type_disallowed(Token const &token, Type *type, char const *format) {
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index 4d8e13f0f..15a0a0b56 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -1129,12 +1129,7 @@ gb_internal lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProc
lbValue init = lb_build_expr(p, init_expr);
if (init.value == nullptr) {
LLVMTypeRef global_type = llvm_addr_type(p->module, var.var);
- if (is_type_untyped_undef(init.type)) {
- // LLVMSetInitializer(var.var.value, LLVMGetUndef(global_type));
- LLVMSetInitializer(var.var.value, LLVMConstNull(global_type));
- var.is_initialized = true;
- continue;
- } else if (is_type_untyped_nil(init.type)) {
+ if (is_type_untyped_nil(init.type)) {
LLVMSetInitializer(var.var.value, LLVMConstNull(global_type));
var.is_initialized = true;
continue;
@@ -2363,8 +2358,7 @@ gb_internal bool lb_generate_code(lbGenerator *gen) {
}
}
}
- if (!var.is_initialized &&
- (is_type_untyped_nil(tav.type) || is_type_untyped_undef(tav.type))) {
+ if (!var.is_initialized && is_type_untyped_nil(tav.type)) {
var.is_initialized = true;
}
}
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp
index 8db6e2a1f..ea25a4594 100644
--- a/src/llvm_backend_const.cpp
+++ b/src/llvm_backend_const.cpp
@@ -1,6 +1,6 @@
gb_internal bool lb_is_const(lbValue value) {
LLVMValueRef v = value.value;
- if (is_type_untyped_nil(value.type) || is_type_untyped_undef(value.type)) {
+ if (is_type_untyped_nil(value.type)) {
// TODO(bill): Is this correct behaviour?
return true;
}
diff --git a/src/llvm_backend_debug.cpp b/src/llvm_backend_debug.cpp
index fd26c41a0..bec719a4a 100644
--- a/src/llvm_backend_debug.cpp
+++ b/src/llvm_backend_debug.cpp
@@ -282,7 +282,7 @@ gb_internal LLVMMetadataRef lb_debug_type_internal(lbModule *m, Type *type) {
case Basic_UntypedString: GB_PANIC("Basic_UntypedString"); break;
case Basic_UntypedRune: GB_PANIC("Basic_UntypedRune"); break;
case Basic_UntypedNil: GB_PANIC("Basic_UntypedNil"); break;
- case Basic_UntypedUndef: GB_PANIC("Basic_UntypedUndef"); break;
+ case Basic_UntypedUninit: GB_PANIC("Basic_UntypedUninit"); break;
default: GB_PANIC("Basic Unhandled"); break;
}
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp
index 69443c9a3..143e38a8d 100644
--- a/src/llvm_backend_expr.cpp
+++ b/src/llvm_backend_expr.cpp
@@ -1486,12 +1486,12 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) {
GB_ASSERT(src != nullptr);
GB_ASSERT(dst != nullptr);
+ if (is_type_untyped_uninit(src)) {
+ return lb_const_undef(m, t);
+ }
if (is_type_untyped_nil(src)) {
return lb_const_nil(m, t);
}
- if (is_type_untyped_undef(src)) {
- return lb_const_undef(m, t);
- }
if (LLVMIsConstant(value.value)) {
if (is_type_any(dst)) {
@@ -2132,12 +2132,12 @@ gb_internal lbValue lb_emit_conv(lbProcedure *p, lbValue value, Type *t) {
if (is_type_any(dst)) {
+ if (is_type_untyped_uninit(src)) {
+ return lb_const_undef(p->module, t);
+ }
if (is_type_untyped_nil(src)) {
return lb_const_nil(p->module, t);
}
- if (is_type_untyped_undef(src)) {
- return lb_const_undef(p->module, t);
- }
lbAddr result = lb_add_local_generated(p, t, true);
@@ -3136,11 +3136,11 @@ gb_internal lbValue lb_build_expr_internal(lbProcedure *p, Ast *expr) {
return lb_addr_load(p, lb_build_addr(p, expr));
case_end;
- case_ast_node(u, Undef, expr)
+ case_ast_node(u, Uninit, expr)
lbValue res = {};
if (is_type_untyped(type)) {
res.value = nullptr;
- res.type = t_untyped_undef;
+ res.type = t_untyped_uninit;
} else {
res.value = LLVMGetUndef(lb_type(m, type));
res.type = type;
diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp
index 7d2f574fe..628c1e5fa 100644
--- a/src/llvm_backend_general.cpp
+++ b/src/llvm_backend_general.cpp
@@ -677,7 +677,7 @@ gb_internal void lb_addr_store(lbProcedure *p, lbAddr addr, lbValue value) {
return;
}
GB_ASSERT(value.type != nullptr);
- if (is_type_untyped_undef(value.type)) {
+ if (is_type_untyped_uninit(value.type)) {
Type *t = lb_addr_type(addr);
value.type = t;
value.value = LLVMGetUndef(lb_type(p->module, t));
@@ -1828,7 +1828,7 @@ gb_internal LLVMTypeRef lb_type_internal(lbModule *m, Type *type) {
case Basic_UntypedString: GB_PANIC("Basic_UntypedString"); break;
case Basic_UntypedRune: GB_PANIC("Basic_UntypedRune"); break;
case Basic_UntypedNil: GB_PANIC("Basic_UntypedNil"); break;
- case Basic_UntypedUndef: GB_PANIC("Basic_UntypedUndef"); break;
+ case Basic_UntypedUninit: GB_PANIC("Basic_UntypedUninit"); break;
}
break;
case Type_Named:
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp
index ddf058668..b8353a466 100644
--- a/src/llvm_backend_proc.cpp
+++ b/src/llvm_backend_proc.cpp
@@ -3218,10 +3218,10 @@ gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) {
Entity *e = params->variables[i];
if (args[i].type == nullptr) {
continue;
+ } else if (is_type_untyped_uninit(args[i].type)) {
+ args[i] = lb_const_undef(m, e->type);
} else if (is_type_untyped_nil(args[i].type)) {
args[i] = lb_const_nil(m, e->type);
- } else if (is_type_untyped_undef(args[i].type)) {
- args[i] = lb_const_undef(m, e->type);
}
}
@@ -3409,10 +3409,10 @@ gb_internal lbValue lb_build_call_expr_internal(lbProcedure *p, Ast *expr) {
Entity *e = param_tuple->variables[i];
if (args[i].type == nullptr) {
continue;
+ } else if (is_type_untyped_uninit(args[i].type)) {
+ args[i] = lb_const_undef(m, e->type);
} else if (is_type_untyped_nil(args[i].type)) {
args[i] = lb_const_nil(m, e->type);
- } else if (is_type_untyped_undef(args[i].type)) {
- args[i] = lb_const_undef(m, e->type);
}
}
}
diff --git a/src/parser.cpp b/src/parser.cpp
index 698ba99ab..bb492fca9 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -115,7 +115,7 @@ gb_internal Ast *clone_ast(Ast *node, AstFile *f) {
n->Ident.entity = nullptr;
break;
case Ast_Implicit: break;
- case Ast_Undef: break;
+ case Ast_Uninit: break;
case Ast_BasicLit: break;
case Ast_BasicDirective: break;
@@ -646,9 +646,9 @@ gb_internal Ast *ast_implicit(AstFile *f, Token token) {
result->Implicit = token;
return result;
}
-gb_internal Ast *ast_undef(AstFile *f, Token token) {
- Ast *result = alloc_ast_node(f, Ast_Undef);
- result->Undef = token;
+gb_internal Ast *ast_uninit(AstFile *f, Token token) {
+ Ast *result = alloc_ast_node(f, Ast_Uninit);
+ result->Uninit = token;
return result;
}
@@ -2092,8 +2092,8 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
case Token_Ident:
return parse_ident(f);
- case Token_Undef:
- return ast_undef(f, expect_token(f, Token_Undef));
+ case Token_Uninit:
+ return ast_uninit(f, expect_token(f, Token_Uninit));
case Token_context:
return ast_implicit(f, expect_token(f, Token_context));
@@ -2292,7 +2292,7 @@ gb_internal Ast *parse_operand(AstFile *f, bool lhs) {
skip_possible_newline_for_literal(f);
- if (allow_token(f, Token_Undef)) {
+ if (allow_token(f, Token_Uninit)) {
if (where_token.kind != Token_Invalid) {
syntax_error(where_token, "'where' clauses are not allowed on procedure literals without a defined body (replaced with ---)");
}
diff --git a/src/parser.hpp b/src/parser.hpp
index aea3bbf21..d4883f287 100644
--- a/src/parser.hpp
+++ b/src/parser.hpp
@@ -373,7 +373,7 @@ gb_global char const *union_type_kind_strings[UnionType_COUNT] = {
Entity *entity; \
}) \
AST_KIND(Implicit, "implicit", Token) \
- AST_KIND(Undef, "undef", Token) \
+ AST_KIND(Uninit, "uninitialized value", Token) \
AST_KIND(BasicLit, "basic literal", struct { \
Token token; \
}) \
diff --git a/src/parser_pos.cpp b/src/parser_pos.cpp
index 1274f05a0..52d49e897 100644
--- a/src/parser_pos.cpp
+++ b/src/parser_pos.cpp
@@ -2,7 +2,7 @@ gb_internal Token ast_token(Ast *node) {
switch (node->kind) {
case Ast_Ident: return node->Ident.token;
case Ast_Implicit: return node->Implicit;
- case Ast_Undef: return node->Undef;
+ case Ast_Uninit: return node->Uninit;
case Ast_BasicLit: return node->BasicLit.token;
case Ast_BasicDirective: return node->BasicDirective.token;
case Ast_ProcGroup: return node->ProcGroup.token;
@@ -137,7 +137,7 @@ Token ast_end_token(Ast *node) {
return empty_token;
case Ast_Ident: return node->Ident.token;
case Ast_Implicit: return node->Implicit;
- case Ast_Undef: return node->Undef;
+ case Ast_Uninit: return node->Uninit;
case Ast_BasicLit: return node->BasicLit.token;
case Ast_BasicDirective: return node->BasicDirective.token;
case Ast_ProcGroup: return node->ProcGroup.close;
diff --git a/src/tokenizer.cpp b/src/tokenizer.cpp
index 547a864fb..17a396b9f 100644
--- a/src/tokenizer.cpp
+++ b/src/tokenizer.cpp
@@ -54,7 +54,7 @@ TOKEN_KIND(Token__AssignOpEnd, ""), \
TOKEN_KIND(Token_Increment, "++"), \
TOKEN_KIND(Token_Decrement, "--"), \
TOKEN_KIND(Token_ArrowRight,"->"), \
- TOKEN_KIND(Token_Undef, "---"), \
+ TOKEN_KIND(Token_Uninit, "---"), \
\
TOKEN_KIND(Token__ComparisonBegin, ""), \
TOKEN_KIND(Token_CmpEq, "=="), \
@@ -917,7 +917,7 @@ gb_internal void tokenizer_get_token(Tokenizer *t, Token *token, int repeat=0) {
token->kind = Token_Decrement;
if (t->curr_rune == '-') {
advance_to_next_rune(t);
- token->kind = Token_Undef;
+ token->kind = Token_Uninit;
}
break;
case '>':
@@ -1078,7 +1078,7 @@ semicolon_check:;
case Token_Imag:
case Token_Rune:
case Token_String:
- case Token_Undef:
+ case Token_Uninit:
/*fallthrough*/
case Token_Question:
case Token_Pointer:
diff --git a/src/types.cpp b/src/types.cpp
index 70c4bcdbe..35fbb719b 100644
--- a/src/types.cpp
+++ b/src/types.cpp
@@ -83,7 +83,7 @@ enum BasicKind {
Basic_UntypedString,
Basic_UntypedRune,
Basic_UntypedNil,
- Basic_UntypedUndef,
+ Basic_UntypedUninit,
Basic_COUNT,
@@ -515,7 +515,7 @@ gb_global Type basic_types[] = {
{Type_Basic, {Basic_UntypedString, BasicFlag_String | BasicFlag_Untyped, 0, STR_LIT("untyped string")}},
{Type_Basic, {Basic_UntypedRune, BasicFlag_Integer | BasicFlag_Untyped, 0, STR_LIT("untyped rune")}},
{Type_Basic, {Basic_UntypedNil, BasicFlag_Untyped, 0, STR_LIT("untyped nil")}},
- {Type_Basic, {Basic_UntypedUndef, BasicFlag_Untyped, 0, STR_LIT("untyped undefined")}},
+ {Type_Basic, {Basic_UntypedUninit, BasicFlag_Untyped, 0, STR_LIT("untyped uninitialized")}},
};
// gb_global Type basic_type_aliases[] = {
@@ -589,7 +589,7 @@ gb_global Type *t_untyped_quaternion = &basic_types[Basic_UntypedQuaternion];
gb_global Type *t_untyped_string = &basic_types[Basic_UntypedString];
gb_global Type *t_untyped_rune = &basic_types[Basic_UntypedRune];
gb_global Type *t_untyped_nil = &basic_types[Basic_UntypedNil];
-gb_global Type *t_untyped_undef = &basic_types[Basic_UntypedUndef];
+gb_global Type *t_untyped_uninit = &basic_types[Basic_UntypedUninit];
@@ -1866,14 +1866,15 @@ gb_internal bool is_type_typeid(Type *t) {
}
gb_internal bool is_type_untyped_nil(Type *t) {
t = base_type(t);
- return (t->kind == Type_Basic && t->Basic.kind == Basic_UntypedNil);
+ // NOTE(bill): checking for `nil` or `---` at once is just to improve the error handling
+ return (t->kind == Type_Basic && (t->Basic.kind == Basic_UntypedNil || t->Basic.kind == Basic_UntypedUninit));
}
-gb_internal bool is_type_untyped_undef(Type *t) {
+gb_internal bool is_type_untyped_uninit(Type *t) {
t = base_type(t);
- return (t->kind == Type_Basic && t->Basic.kind == Basic_UntypedUndef);
+ // NOTE(bill): checking for `nil` or `---` at once is just to improve the error handling
+ return (t->kind == Type_Basic && t->Basic.kind == Basic_UntypedUninit);
}
-
gb_internal bool is_type_empty_union(Type *t) {
t = base_type(t);
return t->kind == Type_Union && t->Union.variants.count == 0;
@@ -2206,10 +2207,6 @@ gb_internal bool is_type_polymorphic(Type *t, bool or_specialized=false) {
}
-gb_internal gb_inline bool type_has_undef(Type *t) {
- return true;
-}
-
gb_internal bool type_has_nil(Type *t) {
t = base_type(t);
switch (t->kind) {