commit c9f8394bf9fc27527b208657d6d9fc7ef625b59c
parent 5e66eae649c6420410620090e0b2a68bb9bcfb1b
Author: m21c <ho*******@gmail.com>
Date: Tue, 23 Jun 2026 17:24:40 +0200
self-dispatch call: fix: handle direct record members
Diffstat:
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/compiler.c b/compiler.c
@@ -385,6 +385,7 @@ enum DeclKind {
typedef
enum DeclFlags {
MSPECIAL = 0x0001,
+ MRECORDMEMBER = 0x0001,
/* MINPORT = 0x0002, ... */
} DeclFlags;
@@ -3170,6 +3171,9 @@ redodeclaration:
}
finish:
+ if (env->kind == SSTRUCT || env->kind == SUNION)
+ decl->flags |= MRECORDMEMBER;
+
result = tokennode(source, decl->u.content);
result->type = ty;
result->u.declref = decl;
@@ -4517,8 +4521,15 @@ substitutedispatch(Env *env, Node *expr)
static Node *
substitutedispatchcall(Env *env, Node *expr)
{
- expr->lhs = substitutedispatch(env, expr->lhs);
+ Decl *field = expr->lhs->u.declref;
+ assert(field);
+ if (field->flags & MRECORDMEMBER) {
+ expr->lhs->kind = ODISP;
+ return expr;
+ }
+
+ expr->lhs = substitutedispatch(env, expr->lhs);
return expr;
}