Skip to main content

parse_solidity_guarded

Function parse_solidity_guarded 

Source
pub fn parse_solidity_guarded(
    source: &str,
) -> Result<(SourceUnit, Vec<Comment>), Vec<Diagnostic>>
Expand description

Run solang_parser::parse(source, 0) on a worker thread with a large bounded stack, joining failures back as ordinary parse diagnostics.

The compiler’s own recursive AST walks are already stacker-guarded (see src/ir/expressions/dispatch/entry.rs), but the parser entry point runs before those guards and solang_parser recurses on its own internal stack. Every call site that parses Solidity source MUST go through this helper — CLI single-file (extract_imports), standard-json import resolution, and parse_source — so the nesting-depth ceiling stays consistent across entry points.

A parser panic (rather than a returned Err) is converted into a normal error diagnostic instead of unwinding into — or aborting — the caller.