harec

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

commit e3a33bc41c7f0200a85ad34ab21ea2b1013dba1b
parent ba13e1099a3818307a3209e5c329130bde791ff9
Author: Eyal Sawady <ecs@d2evs.net>
Date:   Tue, 15 Mar 2022 20:12:45 +0000

Allow enums to promote with ints of the same storage

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

Diffstat:
Msrc/check.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/check.c b/src/check.c @@ -704,6 +704,9 @@ type_promote(struct type_store *store, return promote_const(a, b); } + if (db->storage == STORAGE_ENUM && da->storage == db->_enum.storage) { + return b; + } switch (da->storage) { case STORAGE_ARRAY: if (da->array.length == SIZE_UNDEFINED && da->array.members) { @@ -713,6 +716,11 @@ type_promote(struct type_store *store, return a; } return NULL; + case STORAGE_ENUM: + if (da->_enum.storage == db->storage) { + return a; + } + return NULL; case STORAGE_I8: case STORAGE_I16: case STORAGE_I32: @@ -770,7 +778,6 @@ type_promote(struct type_store *store, return NULL; // Cannot be promoted case STORAGE_BOOL: - case STORAGE_ENUM: case STORAGE_FUNCTION: case STORAGE_RUNE: case STORAGE_SLICE: