aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-06-21 01:33:37 +0100
committergingerBill <bill@gingerbill.org>2023-06-21 01:33:37 +0100
commit735181dc0ec11bdd7293bae01cc07450e5dd788b (patch)
treefc18ab0e4ba99a5cdc0d807052c4e4a33449f327 /src
parent8a890fd3d3cc1d11417d1da37bced9ba5715e612 (diff)
Remove unnecessary indent
Diffstat (limited to 'src')
-rw-r--r--src/check_type.cpp126
1 files changed, 62 insertions, 64 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp
index f241f35ee..a68f83ba9 100644
--- a/src/check_type.cpp
+++ b/src/check_type.cpp
@@ -1665,81 +1665,79 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para
if (operands != nullptr && variables.count < operands->count) {
Operand op = (*operands)[variables.count];
- {
- if (op.expr == nullptr) {
- // NOTE(bill): 2019-03-30
- // This is just to add the error message to determine_type_from_polymorphic which
- // depends on valid position information
- op.expr = _params;
- op.mode = Addressing_Invalid;
- op.type = t_invalid;
- }
- if (is_type_polymorphic_type) {
- type = determine_type_from_polymorphic(ctx, type, op);
- if (type == t_invalid) {
- success = false;
- } else if (!ctx->no_polymorphic_errors) {
- // NOTE(bill): The type should be determined now and thus, no need to determine the type any more
- is_type_polymorphic_type = false;
- Entity *proc_entity = entity_from_expr(op.expr);
- if ((proc_entity != nullptr) && (op.value.kind == ExactValue_Procedure)) {
- if (is_type_polymorphic(proc_entity->type, false)) {
- error(op.expr, "Cannot determine complete type of partial polymorphic procedure");
- }
+ if (op.expr == nullptr) {
+ // NOTE(bill): 2019-03-30
+ // This is just to add the error message to determine_type_from_polymorphic which
+ // depends on valid position information
+ op.expr = _params;
+ op.mode = Addressing_Invalid;
+ op.type = t_invalid;
+ }
+ if (is_type_polymorphic_type) {
+ type = determine_type_from_polymorphic(ctx, type, op);
+ if (type == t_invalid) {
+ success = false;
+ } else if (!ctx->no_polymorphic_errors) {
+ // NOTE(bill): The type should be determined now and thus, no need to determine the type any more
+ is_type_polymorphic_type = false;
+ Entity *proc_entity = entity_from_expr(op.expr);
+ if ((proc_entity != nullptr) && (op.value.kind == ExactValue_Procedure)) {
+ if (is_type_polymorphic(proc_entity->type, false)) {
+ error(op.expr, "Cannot determine complete type of partial polymorphic procedure");
}
}
}
- if (is_poly_name) {
- bool valid = false;
- if (is_type_proc(op.type)) {
- Ast *expr = unparen_expr(op.expr);
- Entity *proc_entity = entity_from_expr(expr);
- if (proc_entity) {
- poly_const = exact_value_procedure(proc_entity->identifier.load() ? proc_entity->identifier.load() : op.expr);
- valid = true;
- } else if (expr->kind == Ast_ProcLit) {
- poly_const = exact_value_procedure(expr);
- valid = true;
- }
- }
- if (!valid) {
- if (op.mode == Addressing_Constant) {
- poly_const = op.value;
- } else {
- error(op.expr, "Expected a constant value for this polymorphic name parameter, got %s", expr_to_string(op.expr));
- success = false;
- }
+ }
+ if (is_poly_name) {
+ bool valid = false;
+ if (is_type_proc(op.type)) {
+ Ast *expr = unparen_expr(op.expr);
+ Entity *proc_entity = entity_from_expr(expr);
+ if (proc_entity) {
+ poly_const = exact_value_procedure(proc_entity->identifier.load() ? proc_entity->identifier.load() : op.expr);
+ valid = true;
+ } else if (expr->kind == Ast_ProcLit) {
+ poly_const = exact_value_procedure(expr);
+ valid = true;
}
}
- if (type != t_invalid && !check_is_assignable_to(ctx, &op, type)) {
- bool ok = true;
- if (p->flags&FieldFlag_any_int) {
- if ((!is_type_integer(op.type) && !is_type_enum(op.type)) || (!is_type_integer(type) && !is_type_enum(type))) {
- ok = false;
- } else if (!check_is_castable_to(ctx, &op, type)) {
- ok = false;
- }
- }
- if (!ok) {
+ if (!valid) {
+ if (op.mode == Addressing_Constant) {
+ poly_const = op.value;
+ } else {
+ error(op.expr, "Expected a constant value for this polymorphic name parameter, got %s", expr_to_string(op.expr));
success = false;
- #if 0
- gbString got = type_to_string(op.type);
- gbString expected = type_to_string(type);
- error(op.expr, "Cannot assigned type to parameter, got type '%s', expected '%s'", got, expected);
- gb_string_free(expected);
- gb_string_free(got);
- #endif
}
}
-
- if (is_type_untyped(default_type(type))) {
- gbString str = type_to_string(type);
- error(op.expr, "Cannot determine type from the parameter, got '%s'", str);
- gb_string_free(str);
+ }
+ if (type != t_invalid && !check_is_assignable_to(ctx, &op, type)) {
+ bool ok = true;
+ if (p->flags&FieldFlag_any_int) {
+ if ((!is_type_integer(op.type) && !is_type_enum(op.type)) || (!is_type_integer(type) && !is_type_enum(type))) {
+ ok = false;
+ } else if (!check_is_castable_to(ctx, &op, type)) {
+ ok = false;
+ }
+ }
+ if (!ok) {
success = false;
- type = t_invalid;
+ #if 0
+ gbString got = type_to_string(op.type);
+ gbString expected = type_to_string(type);
+ error(op.expr, "Cannot assigned type to parameter, got type '%s', expected '%s'", got, expected);
+ gb_string_free(expected);
+ gb_string_free(got);
+ #endif
}
}
+
+ if (is_type_untyped(default_type(type))) {
+ gbString str = type_to_string(type);
+ error(op.expr, "Cannot determine type from the parameter, got '%s'", str);
+ gb_string_free(str);
+ success = false;
+ type = t_invalid;
+ }
}
if (p->flags&FieldFlag_no_alias) {