From d62f189d7261160a2d3c66bfba2fda182a863fbd Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sun, 15 Aug 2021 15:09:47 +0100 Subject: [PATCH] Remove some dead code --- src/check_builtin.cpp | 9 ++------- src/check_expr.cpp | 17 ++--------------- src/parser.hpp | 5 +++-- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 88b643d10..846bea296 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -48,7 +48,7 @@ BuiltinTypeIsProc *builtin_type_is_procs[BuiltinProc__type_simple_boolean_end - }; -void check_try_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_) { +void check_or_else_split_types(CheckerContext *c, Operand *x, String const &name, Type **left_type_, Type **right_type_) { Type *left_type = nullptr; Type *right_type = nullptr; if (x->type->kind == Type_Tuple) { @@ -75,11 +75,6 @@ void check_try_split_types(CheckerContext *c, Operand *x, String const &name, Ty error(x->expr, "'%.*s' expects an \"optional ok\" like value, got %s", LIT(name), str); gb_string_free(str); } - // if (!type_has_nil(right_type) && !is_type_boolean(right_type)) { - // gbString str = type_to_string(right_type); - // error(x->expr, "'%.*s' expects an \"optional ok\" like value, or an n-valued expression where the last value is either a boolean or can be compared against 'nil', got %s", LIT(name), str); - // gb_string_free(str); - // } } @@ -1829,7 +1824,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 Type *left_type = nullptr; Type *right_type = nullptr; - check_try_split_types(c, &x, builtin_name, &left_type, &right_type); + check_or_else_split_types(c, &x, builtin_name, &left_type, &right_type); add_type_and_value(&c->checker->info, arg, x.mode, x.type, x.value); if (left_type != nullptr) { diff --git a/src/check_expr.cpp b/src/check_expr.cpp index b185dd080..f01e9a328 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -662,23 +662,10 @@ i64 check_distance_between_types(CheckerContext *c, Operand *operand, Type *type if (expr->kind == Ast_AutoCast) { Operand x = *operand; x.expr = expr->AutoCast.expr; - bool ok = check_cast_internal(c, &x, type); - if (ok) { + if (check_cast_internal(c, &x, type)) { return MAXIMUM_TYPE_DISTANCE; } - } /*else if (expr->kind == Ast_CallExpr) { - // NOTE(bill, 2021-04-19): Allow assignment of procedure calls with #optional_ok - ast_node(ce, CallExpr, expr); - Type *pt = base_type(type_of_expr(ce->proc)); - if (pt->kind == Type_Proc && pt->Proc.optional_ok) { - Operand x = *operand; - x.type = pt->Proc.results->Tuple.variables[0]->type; - i64 res = check_distance_between_types(c, &x, type); - if (res >= 0) { - return res+1; - } - } - }*/ + } } return -1; diff --git a/src/parser.hpp b/src/parser.hpp index 02d6b2c64..c284ec586 100644 --- a/src/parser.hpp +++ b/src/parser.hpp @@ -277,10 +277,11 @@ enum FieldFlag : u32 { FieldFlag_const = 1<<5, FieldFlag_any_int = 1<<6, - FieldFlag_Tags = 1<<10, - + // Internal use by the parser only + FieldFlag_Tags = 1<<10, FieldFlag_Results = 1<<16, + // Parameter List Restrictions FieldFlag_Signature = FieldFlag_ellipsis|FieldFlag_using|FieldFlag_no_alias|FieldFlag_c_vararg|FieldFlag_auto_cast|FieldFlag_const|FieldFlag_any_int, FieldFlag_Struct = FieldFlag_using|FieldFlag_Tags, };