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

commit aa6d14a8ef21b29376b73e95065c9a44e5960ff6
parent 96035b93f93d4c70d024b2aa3422a86666d3c8c2
Author: Bor Grošelj Simić <bor.groseljsimic@telemach.net>
Date:   Mon,  4 Oct 2021 21:35:03 +0200

type_store: don't initialize types that can't be referenced

All derivative types of a type alias will always have set a superset of
flags the alias was defined with.

Consider `type foo = !void;`.
Such a definition leaves no way to create a value of type "foo, but
without the TYPE_ERROR type flag", so there is no need to put such a
type into the type store. Similar logic applies to const flag, so we can
just ignore any flag combination that is a strict subset of the flags of
the alias-type's secondary type.

Signed-off-by: Bor Grošelj Simić <bor.groseljsimic@telemach.net>

Msrc/type_store.c | 3+++
1 file changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/type_store.c b/src/type_store.c @@ -886,6 +886,9 @@ type_store_lookup_alias(struct type_store *store, TYPE_ERROR | TYPE_CONST, }; for (size_t i = 0; i < sizeof(flags) / sizeof(flags[0]); i++) { + if ((flags[i] & secondary->flags) != secondary->flags) { + continue; + } const struct type *flagged = type_store_lookup_with_flags(store, secondary, flags[i]); alias.flags = flagged->flags;