harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit d7f8bc5dde6f51f8b1f869985202000907c406b3
parent 22af770020c541fa2643e477614d4e772ccc91c5
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Fri,  8 Apr 2022 15:52:50 +0000

Fix casting constants to type aliases

Need to avoid dealiasing to/from before saving the original values. Also
applies to assignability.

Fixes https://todo.sr.ht/~sircmpwn/hare/602

Signed-off-by: Eyal Sawady <ecs@d2evs.net>

Diffstat:
Msrc/types.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/types.c b/src/types.c @@ -720,6 +720,7 @@ struct_subtype(const struct type *to, const struct type *from) { bool type_is_assignable(const struct type *to, const struct type *from) { + const struct type *to_orig = to, *from_orig = from; if (type_dealias(to)->storage != STORAGE_TAGGED) { to = type_dealias(to); from = type_dealias(from); @@ -727,7 +728,6 @@ type_is_assignable(const struct type *to, const struct type *from) // const and non-const types are mutually assignable struct type _to, _from; - const struct type *to_orig = to, *from_orig = from; to = strip_flags(to, &_to), from = strip_flags(from, &_from); if (to->id == from->id && to->storage != STORAGE_VOID) { return true; @@ -902,13 +902,13 @@ type_is_castable(const struct type *to, const struct type *from) return is_castable_with_tagged(to, from); } + const struct type *to_orig = to, *from_orig = from; to = type_dealias(to), from = type_dealias(from); if (to == from) { return true; } struct type _to, _from; - const struct type *to_orig = to, *from_orig = from; to = strip_flags(to, &_to), from = strip_flags(from, &_from); if (to->id == from->id) { return true;