Skip to content

Commit

Permalink
Revert "add error to self hosted"
Browse files Browse the repository at this point in the history
This reverts commit cb58286.
  • Loading branch information
Akuli committed Dec 19, 2023
1 parent cb58286 commit 6fc48bf
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions self_hosted/typecheck.jou
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ def can_cast_implicitly(from: Type*, to: Type*) -> bool:
)

def can_cast_explicitly(from: Type*, to: Type*) -> bool:
return from != to and (
(from->kind == TypeKind::Array and to->kind == TypeKind::Pointer and from->array.item_type == to->value_type)
return (
from == to
or (from->kind == TypeKind::Array and to->kind == TypeKind::Pointer and from->array.item_type == to->value_type)
or (from->is_pointer_type() and to->is_pointer_type())
or (from->is_number_type() and to->is_number_type())
or (from->is_integer_type() and to->kind == TypeKind::Enum)
Expand Down Expand Up @@ -177,10 +178,7 @@ class ExpressionTypes:
from = self->original_type
if not can_cast_explicitly(from, to):
message: byte[500]
if from == to:
snprintf(message, sizeof message, "unnecessary cast from %s to %s", from->name, to->name)
else:
snprintf(message, sizeof message, "cannot cast from type %s to %s", from->name, to->name)
snprintf(&message[0], sizeof message, "cannot cast from type %s to %s", from->name, to->name)
fail(error_location, message)

if from->kind == TypeKind::Array and to->is_pointer_type():
Expand Down

0 comments on commit 6fc48bf

Please sign in to comment.