Skip to content

Commit 870f599

Browse files
fix(soroban): reject unsupported ABI types before codegen
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 #1897 while keeping supported event emission, public string accessors, internal bytes helpers, and non-Soroban targets unaffected. Signed-off-by: mohamedbasuony <mohamedbasuony@aucegypt.edu>
1 parent 0f0e2e4 commit 870f599

4 files changed

Lines changed: 804 additions & 3 deletions

File tree

src/codegen/mod.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,18 @@ fn contract(contract_no: usize, ns: &mut Namespace, opt: &Options) {
302302
if !ns.diagnostics.any_errors() && ns.contracts[contract_no].instantiable {
303303
layout(contract_no, ns);
304304

305+
if ns.target == Target::Soroban {
306+
soroban::validate_accessor_abi_types(contract_no, ns);
307+
if ns.diagnostics.any_errors() {
308+
return;
309+
}
310+
311+
soroban::validate_event_abi_types(contract_no, ns);
312+
if ns.diagnostics.any_errors() {
313+
return;
314+
}
315+
}
316+
305317
let mut cfg_no = 0;
306318
let mut all_cfg = Vec::new();
307319

@@ -359,6 +371,13 @@ fn contract(contract_no: usize, ns: &mut Namespace, opt: &Options) {
359371
ns.contracts[contract_no].default_constructor = Some((func, cfg_no));
360372
}
361373

374+
if ns.target == Target::Soroban {
375+
soroban::validate_abi_types(&all_cfg, ns);
376+
if ns.diagnostics.any_errors() {
377+
return;
378+
}
379+
}
380+
362381
for mut dispatch_cfg in function_dispatch(contract_no, &mut all_cfg, ns, opt) {
363382
optimize_and_check_cfg(&mut dispatch_cfg, ns, ASTFunction::None, opt);
364383
all_cfg.push(dispatch_cfg);

0 commit comments

Comments
 (0)