diff --git a/App/lib/core/Gen/ExprGenAttr.vp b/App/lib/core/Gen/ExprGenAttr.vp index 993cf4f..9ac1431 100644 --- a/App/lib/core/Gen/ExprGenAttr.vp +++ b/App/lib/core/Gen/ExprGenAttr.vp @@ -789,6 +789,18 @@ class ExprGenAttr(ExprGenBase.ExprGenBase): # 查找字段索引和类型 field_info: GenTypes.FieldEntry | t.CPtr = self.Gen.StructGen.lookup_field( struct_ty, at.attr) + # [GAP-DIAG] 定位 th.arg=arg 字段索引错(func/arg 都解析成 3)根因: + # 打印字段名/结构体类型名/查到的索引与实际字段名 + if field_info is not None \ + and (string.strcmp(at.attr, "arg") == 0 or string.strcmp(at.attr, "func") == 0): + dbg_gap: str = pool.alloc(200) + if dbg_gap is not None: + ty_nm_gap: str = self.Gen.StructGen._extract_struct_name(struct_ty) + if ty_nm_gap is None: + ty_nm_gap = "?" + viperlib.snprintf(dbg_gap, 200, "[GAP] attr=%s ty=%s idx=%d fe_name=%s\n", + at.attr, ty_nm_gap, field_info.Index, field_info.Name) + stdio.printf("%s", dbg_gap) # REnum 变体字段查找: lookup_field 失败时,尝试 REnum 别名 # REnum 结构体字段名是 _p1/_p2/...,但源码用变体字段名访问(如 ty.Pointee) if field_info is None: