solang icon indicating copy to clipboard operation
solang copied to clipboard

fix: resolve panic when UserType appears as struct member

Open mansiverma897993 opened this issue 5 months ago • 0 comments

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) in Type::storage_align by recursing into its underlying resolved type:
    Type::UserType(no) => ns.user_types[*no].ty.storage_align(ns),
    

mansiverma897993 avatar Jun 19 '26 09:06 mansiverma897993