Skip to content

fix: resolve panic when UserType appears as struct member#1924

Open
mansiverma897993 wants to merge 1 commit into
hyperledger-solang:mainfrom
mansiverma897993:fix-usertype-struct-panic
Open

fix: resolve panic when UserType appears as struct member#1924
mansiverma897993 wants to merge 1 commit into
hyperledger-solang:mainfrom
mansiverma897993:fix-usertype-struct-panic

Conversation

@mansiverma897993

@mansiverma897993 mansiverma897993 commented Jun 19, 2026

Copy link
Copy Markdown

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),

Signed-off-by: mansiverma897993 <vmansi756@gmail.com>
@mansiverma897993 mansiverma897993 force-pushed the fix-usertype-struct-panic branch from 9f44ce8 to 108fa15 Compare June 19, 2026 09:11
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.

Not implemented at types.rs:1837 (Solang v0.3.4 --target solana)

1 participant