Skip to content

refactor(semantic): introduce TypeMember abstraction for unified struct/tuple member access#9883

Draft
orizi wants to merge 1 commit intomainfrom
orizi/04-25-refactor_semantic_introduce_typemember_abstraction_for_unified_struct_tuple_member_access
Draft

refactor(semantic): introduce TypeMember abstraction for unified struct/tuple member access#9883
orizi wants to merge 1 commit intomainfrom
orizi/04-25-refactor_semantic_introduce_typemember_abstraction_for_unified_struct_tuple_member_access

Conversation

@orizi
Copy link
Copy Markdown
Collaborator

@orizi orizi commented Apr 29, 2026

Summary

Introduces TypeMember and TypeMemberKind as a unified abstraction over named struct members and positional tuple elements. Adds a new type_members query (backed by type_members_query) that returns a type's accessible members keyed by their access name — struct member names for structs, and stringified indices ("0", "1", ...) for tuples. Updates EnrichedTypeMemberAccess and EnrichedMembers to use TypeMember instead of Member, and updates member_access_expr and get_enriched_type_member_access to go through the new type_members query rather than calling concrete_struct_members directly.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

Previously, member access resolution only handled concrete struct types by calling concrete_struct_members directly, with no shared abstraction for tuple element access. This made it impossible to unify member access logic across structs and tuples, and left tuple element access (e.g., my_tuple.0) unsupported through the enriched member access path.


What was the behavior or documentation before?

Member access enrichment operated exclusively on concrete_struct_members, returning Member values. Tuple types returned an empty map by default, and there was no TypeMember abstraction to distinguish between struct members and tuple elements.


What is the behavior or documentation after?

A new TypeMember struct and TypeMemberKind enum unify struct members and tuple elements. The type_members query returns members for both structs and tuples. The enriched member access path now uses TypeMember throughout. Tuple element access via numeric index names is structurally supported, with full handling gated behind a TODO referencing issue #7608.


Related issue or discussion (if any)

#7608


Additional context

The member_access_expr function currently returns Unsupported for TypeMemberKind::TupleElement accesses, as noted by the TODO(#7608) comment. The groundwork laid here is intended to be completed in that follow-up.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

Copy link
Copy Markdown
Collaborator Author

orizi commented Apr 29, 2026

@orizi orizi force-pushed the orizi/04-25-refactor_semantic_introduce_typemember_abstraction_for_unified_struct_tuple_member_access branch from e0ec9a0 to 22810ca Compare April 29, 2026 12:23
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.

2 participants