harec

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

commit b4023bd56ce37e03904ddafc59dba5b4c5bce8f6
parent b2c76aa4e2064912f9fa8b5d30f06d130cd59b37
Author: Alexey Yerin <yyp@disroot.org>
Date:   Sun, 24 Oct 2021 21:57:55 +0300

types: strip flags when checking for castability

This allows, for example, to cast 'str' to '!str' and backwards, which
is useful when there are multiple error variants with the same
representation.

Signed-off-by: Alexey Yerin <yyp@disroot.org>

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

diff --git a/src/types.c b/src/types.c @@ -719,6 +719,12 @@ type_is_castable(const struct type *to, const struct type *from) return true; } + struct type _to, _from; + to = strip_flags(to, &_to), from = strip_flags(from, &_from); + if (to->id == from->id) { + return true; + } + switch (from->storage) { case STORAGE_FCONST: case STORAGE_ICONST: