c3c
c3c copied to clipboard
Assertion when has_tagof is accidentally called on fn type
This was a typo in my code, but rather than a nice error message it produced a nasty assertion
struct Foo { int a; }
struct Bar { int a; }
fn void Bar.xyz(&self) @tag("footag", 123) {}
macro void Foo.tags(&self, other)
{
// inner to remove pointer
var $Type = $typefrom($typeof(other).inner);
$echo "$Type is " +++ $Type.nameof;
var $methodcount = $Type.methodsof.len;
$for (var $i = 0; $i < $methodcount; $i++)
//var $MethodType = $typeof($Type.$eval($Type.methodsof[$i])); // OK
var $MethodType = $typeof(&$Type.$eval($Type.methodsof[$i])); // BAD
// ^ TYPO &
$echo "$MethodType is " +++ $MethodType.nameof;
var $hasfootag = $MethodType.has_tagof("footag");
$endfor
}
fn void main() { Bar bar; Foo foo; foo.tags(&bar); }
Output
] $Type is Bar
] $MethodType is fn void(Bar*)
Assertion failed: (decl->resolved_attributes), function sema_expr_analyse_tagof, file sema_expr.c, line 2498.
zsh: abort c3c compile repro-tags.c3
This should work now.
Please check and close the issue if it is ok.
Both forms now report $MethodType is fn void(Bar*)