Skip to content

fix(soroban): reject unsupported ABI types before codegen#1903

Open
mohamedbasuony wants to merge 1 commit into
hyperledger-solang:mainfrom
mohamedbasuony:fix/soroban-error-reporting-1897
Open

fix(soroban): reject unsupported ABI types before codegen#1903
mohamedbasuony wants to merge 1 commit into
hyperledger-solang:mainfrom
mohamedbasuony:fix/soroban-error-reporting-1897

Conversation

@mohamedbasuony
Copy link
Copy Markdown
Contributor

@mohamedbasuony mohamedbasuony commented May 12, 2026

Summary

Fixes the compiler-side Soroban diagnostics covered by #1897.

Unsupported Soroban paths could previously reach codegen, Soroban encoder/decoder logic, spec emission, or LLVM and fail with internal panics, todo!(), unimplemented!(), Inkwell errors, or LLVM assertions. This PR adds Soroban codegen-side validation so those user-triggerable cases are reported as normal Solang diagnostics before the unsafe paths are reached.

What changed

  • Move unsupported Soroban ABI validation out of sema and into the Soroban codegen path.
  • Validate unsupported public/external Soroban function parameters and return values before dispatch wrapper generation.
  • Validate unsupported public accessor return values before generated accessor code can reach unsupported Soroban lowering.
  • Validate unsupported Soroban event argument types before event encoding.
  • Guard multiple external return values and unsupported array/struct/string/bytes cases that could otherwise reach Soroban spec, encoder/decoder, Inkwell, or LLVM failures.
  • Add precise diagnostics for internal string-helper patterns that could otherwise trigger LLVM/Inkwell failures.
  • Keep supported Soroban behavior unchanged, including supported event emission and public string accessors.
  • Target-gate the Soroban validation and early returns so non-Soroban diagnostic accumulation is unchanged.

Notes

  • This does not catch panics globally.
  • This does not wrap compiler execution.
  • This does not suppress LLVM assertions.
  • Unsupported Soroban cases are rejected before the relevant codegen/emit paths are reached.
  • Non-Soroban targets are not affected by these Soroban diagnostics.

Verification

Ran locally:

  • cargo fmt --all -- --check
  • cargo build --workspace
  • cargo test --test soroban
  • cargo test --test contract solana_contracts -- --nocapture
  • cargo clippy --workspace
  • cargo test --workspace

Manual checks:

  • dynamic_bytes_arg.sol: emits a normal diagnostic; old Soroban decoder panic is gone.
  • string_return.sol: emits a normal diagnostic; old LLVM abort is gone.
  • event_panic.sol: still compiles on this checkout.
  • examples/soroban/token.sol: still compiles with existing warnings.
  • Unsupported event argument stress cases emit diagnostics instead of panicking.
  • Internal string-helper stress cases emit diagnostics instead of reaching LLVM/Inkwell failures.
  • Public string accessor, internal bytes helper, and non-Soroban bytes/string controls remain unaffected.

Fixes #1897.

@mohamedbasuony mohamedbasuony force-pushed the fix/soroban-error-reporting-1897 branch from 5d3f8fc to 85c288a Compare May 12, 2026 21:25
@salaheldinsoliman
Copy link
Copy Markdown
Contributor

This change shouldn't be in sema. Instead, it should be handled in codegen, where target specific encoding/decoding logic is implemented .
Moreover, I expected to see:
1- panic!s without error messages addressed
2- Areas where LLVM panics could occur safely guarded by human readbale messages.

Changes should be mostly in emit and codegen

Copy link
Copy Markdown
Contributor

@salaheldinsoliman salaheldinsoliman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a comment

@mohamedbasuony
Copy link
Copy Markdown
Contributor Author

Thanks, I see your point. I put the checks in sema as target validation, but I agree that this is too early/general for Soroban-specific ABI handling. The PR will be updated so that it handles unsupported Soroban ABI cases in the emit/codegen path, closer to the encoding/decoding logic.

Move unsupported Soroban ABI validation into the Soroban codegen path before dispatch wrapper generation, encoder/decoder lowering, spec emission, and LLVM emission can hit unsupported constructs.

Add diagnostics for unsupported Soroban external/public ABI surfaces, including unsupported bytes parameters, bytes/string/struct/array returns, public accessor returns, multiple external returns, unsupported event argument types, and internal string-helper patterns that could otherwise reach LLVM/Inkwell failures.

Target-gate the Soroban validation and early returns so non-Soroban diagnostic accumulation remains unchanged.

This avoids user-triggerable panic!, todo!, unimplemented!, and LLVM assertion paths from hyperledger-solang#1897 while keeping supported event emission, public string accessors, internal bytes helpers, and non-Soroban targets unaffected.

Signed-off-by: mohamedbasuony <mohamedbasuony@aucegypt.edu>
@mohamedbasuony mohamedbasuony force-pushed the fix/soroban-error-reporting-1897 branch from 85c288a to 870f599 Compare May 13, 2026 17:16
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.

Improve error reporting

2 participants