Skip to content

fix(struct): 修正 @fieldParentPtr 示例的返回类型 - #419

Merged
jinzhongjia merged 1 commit into
mainfrom
fix/struct-field-parent-ptr
Nov 21, 2026
Merged

jinzhongjia merged 1 commit into
mainfrom
fix/struct-field-parent-ptr

Conversation

@jinzhongjia

Copy link
Copy Markdown
Member

Closes #408

  • course/code/17/struct.zig 与 course/code/release/struct.zig 中 @fieldParentPtr("x", x) 的结果类型由 Point 改为 *Point
  • setYBasedOnX 之前没有被任何代码引用,惰性分析不会检查它,因此错误一直未被发现;新增 test "base ptr" 调用该函数,使其参与编译检查
  • 旧版本示例保持不变

验证:Zig 0.17.1 下修复前新测试报 expected pointer type, found 'struct.BasePtr.Point',修复后 zig test 通过,根目录 zig build 通过。

- 0.17 与 release 示例中 @fieldParentPtr 的结果类型由 Point 改为 *Point
- 新增 base ptr 测试调用 setYBasedOnX,使该函数参与编译检查
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@jinzhongjia
jinzhongjia merged commit 9b2af88 into main Nov 21, 2026
43 of 45 checks passed
@jinzhongjia
jinzhongjia deleted the fix/struct-field-parent-ptr branch November 21, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

从字段获取结构体基指针的示例代码类型问题

1 participant