commit 72323d78aeb57be20b4058e4f57256af1cbdccf8
parent 1f9e16fecf97219dfc8439d0ab1b2740095dd56a
Author: Drew DeVault <sir@cmpwn.com>
Date: Fri, 25 Dec 2020 10:19:44 -0500
check: conform binding type flags behavior
Following spec clarifications
Diffstat:
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/check.c b/src/check.c
@@ -162,12 +162,15 @@ check_expr_binding(struct context *ctx,
if (abinding->type) {
type = type_store_lookup_atype(
&ctx->store, abinding->type);
- // TODO: Check assignability of initializer
+ type = type_store_lookup_with_flags(&ctx->store,
+ type, type->flags | abinding->flags);
} else {
type = type_store_lookup_with_flags(&ctx->store,
initializer->result, abinding->flags);
}
+ // TODO: Check assignability of initializer
+
const struct scope_object *obj = scope_insert(ctx->scope,
O_BIND, &ident, type);
binding->object = obj;
diff --git a/src/type_store.c b/src/type_store.c
@@ -472,11 +472,11 @@ const struct type *
type_store_lookup_with_flags(struct type_store *store,
const struct type *type, unsigned int flags)
{
- if ((type->flags & ~flags) == flags) {
+ if (type->flags == flags) {
return type;
}
struct type new = *type;
- new.flags |= flags;
+ new.flags = flags;
return type_store_lookup_type(store, &new);
}