Updated fix of #2218

This commit is contained in:
Christoffer Lerno
2025-06-24 22:28:14 +02:00
parent 11b8a9808d
commit faf073885f
2 changed files with 21 additions and 0 deletions

View File

@@ -1540,8 +1540,14 @@ static bool rule_bits_to_int(CastContext *cc, bool is_explicit, bool is_silent)
if (is_silent && !is_explicit) return false;
Type *base_type = cc->from->decl->strukt.container_type->type->canonical;
Type *to = cc->to;
RETRY:
if (base_type != to)
{
if (base_type->type_kind == TYPE_DISTINCT && (base_type->decl->is_substruct || is_explicit))
{
base_type = base_type->decl->distinct->type->canonical;
goto RETRY;
}
if (!type_is_integer(base_type) || type_size(to) != type_size(base_type))
{
return sema_cast_error(cc, false, is_silent);

View File

@@ -0,0 +1,15 @@
typedef Foo = int;
bitstruct Bar : Foo
{
bool a;
}
fn int main()
{
Bar b;
(Foo)b;
(int)b;
($typefrom(Bar.inner))b;
return 0;
}