solang
solang copied to clipboard
fix: resolve panic when UserType appears as struct member
Description
This PR resolves an internal compiler panic that occurred when a user-defined value type (such as type C is address;) was used as a member of a struct (fixes #1920).
Root Cause
During semantic analysis for target Solana, layout and alignment calculations are performed on struct fields. However, Type::storage_align and Type::align_of in src/sema/types.rs did not handle the Type::UserType variant, triggering the fallback wildcard panic (unimplemented!()).
Fix
- Handled
Type::UserType(no)inType::storage_alignby recursing into its underlying resolved type:Type::UserType(no) => ns.user_types[*no].ty.storage_align(ns),