Skip to content

fix(hy-check): reject field selectors on pointers to non-struct and multi-pointer types (#4403) - #4448

Open
SuperPiIot wants to merge 1 commit into
limitlessprojects:mainfrom
SuperPiIot:fix/ptr-non-struct-field-selector-4403
Open

SuperPiIot wants to merge 1 commit into
limitlessprojects:mainfrom
SuperPiIot:fix/ptr-non-struct-field-selector-4403

Conversation

@SuperPiIot

Copy link
Copy Markdown

Summary

Fixes #4403

In check_field_selector_kind (compiler/crates/hy-check/src/buildable.rs), every OpKind::Pointer(_) was previously treated as struct-like. Because struct_base_name returns None for non-struct pointers (*int, *string, *[]T, *map[K]V, *bool, *chan T) and recursively unwraps multi-level pointers (**T), selectors through those types had is_struct_like == true && struct_known == false and returned early without emitting HYB-E1002. As a result, hyb check accepted invalid selectors that fail go build with undefined (type ... has no field or method ...).

This PR restricts is_struct_like in check_field_selector_kind to direct OpKind::Struct(_) and single-level OpKind::Pointer(OpKind::Struct(_)), so selectors on pointers to non-structs and multi-level pointers (**int, **S) fail closed with HYB-E1002 on both reads and stores, while preserving field/method access on *S and generic *box[T].

Verification

  • Added compiler/crates/hy-check/tests/pointer_to_non_struct_field_selector.rs covering reads and stores on *int, *string, *[]int, *map[string]int, *bool, *chan int, **int, **pt, *pt, and *box[int].
  • cargo test --manifest-path compiler/Cargo.toml -p hy-check --lib --test pointer_to_non_struct_field_selector --test emit_build_guards --test member_defer_and_append_guards: 234 passed, 0 failed (184 lib + 31 emit_build_guards + 9 member_defer_and_append_guards + 10 new tests).

Payout Wallet

  • Network: Base Mainnet (Chain ID 8453)
  • Asset: USDC
  • Wallet: 0xf084cF0076F91AA48C2370F427C399dAA8C1f07F

@github-actions github-actions Bot added the bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify()) label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:land-candidate Shepherd: fresh, gate-clean, verifiable (set from classify())

Projects

None yet

1 participant