types::has_equals fails with assert for bitstructs #2377

This commit is contained in:
Christoffer Lerno
2025-08-11 20:53:02 +02:00
parent 625a6d987d
commit be98a01ed8
3 changed files with 91 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
module test;
bitstruct Foo : int
{
bool foo;
}
bitstruct Foo2 : int
{
bool a : 1;
int b : 7..9;
}
fn void main()
{
var $foo = (Foo) { true };
var $bar = (Foo) { };
bool $baz = $foo == $bar;
$assert($baz == false);
$baz = $foo == $foo;
$assert($baz == true);
$assert(true == types::has_equals(Foo));
Foo2 $a1 = { true, 2 };
Foo2 $a2 = {};
Foo2 $a3 = { true, 3 };
Foo2 $a4 = { false, 0 };
$assert(!($a1 == $a2));
$assert($a1 != $a2);
$assert($a2 == $a2);
$assert(!($a2 != $a2));
$assert($a1 != $a3);
$assert(!($a1 == $a3));
$assert($a4 == $a2);
$assert(!($a4 != $a2));
}