Skip to content

Implement AST multi-error recovery - #383

Open
LesterEvSe wants to merge 4 commits into
BlockstreamResearch:masterfrom
LesterEvSe:feat/ast-multierrors
Open

Implement AST multi-error recovery#383
LesterEvSe wants to merge 4 commits into
BlockstreamResearch:masterfrom
LesterEvSe:feat/ast-multierrors

Conversation

@LesterEvSe

Copy link
Copy Markdown
Collaborator

Analysis now reports every independent error in one pass instead of stopping at
the first.

  • Poison, not fake values; Error variants in the parse tree, AST, and type
    system (TypeInner::Error); recovery emits these instead of fabricated units,
    aliases, or sizes.
  • No cascades; poisoned types are absorbed during analysis (is_error guards
    and ResolvedType::compatible), so one broken construct does not spawn secondary
    errors.
  • Collect, do not abort; Scope carries a diagnostics sink; containers record
    an error and keep analyzing siblings, and Program::analyze returns Option.
  • Parser split; parse_from_str (fragments, first error) vs
    parse_from_content (files, collect all), over one shared core.

@LesterEvSe
LesterEvSe requested a review from KyrylR July 28, 2026 15:51
@LesterEvSe LesterEvSe self-assigned this Jul 28, 2026
@LesterEvSe
LesterEvSe requested a review from delta1 as a code owner July 28, 2026 15:51
This was linked to issues Jul 28, 2026
@LesterEvSe
LesterEvSe force-pushed the feat/ast-multierrors branch 7 times, most recently from ad880be to a378398 Compare July 30, 2026 13:43
@LesterEvSe
LesterEvSe force-pushed the feat/ast-multierrors branch 5 times, most recently from 5b353a1 to fdd2abb Compare August 12, 2026 11:23
@LesterEvSe
LesterEvSe force-pushed the feat/ast-multierrors branch from fdd2abb to 5202cc8 Compare August 12, 2026 14:06
@apoelstra

Copy link
Copy Markdown
Contributor

In 763b2d8:

I think we should call the Error type "Uninhabited" (or "Never" if we want to be Rust-like), and similarly the is_error method should be is_uninhabited (or is_never or is_empty ... though I think is_empty would be confusing because it's such a common name in Rust).

The empty type has the properties you want -- it cannot be constructed, no code should ever be compiled which accepts it, and there is a unique function mapping it to every other type, and I'd like to add it to the language anyway, so we might as well add it here.

In 8a1b03c:

Adds a blank line to witness.rs, otherwise doesn't touch the file.

@LesterEvSe
LesterEvSe force-pushed the feat/ast-multierrors branch 2 times, most recently from 4e826ec to 43e843e Compare August 17, 2026 08:45
@LesterEvSe
LesterEvSe force-pushed the feat/ast-multierrors branch from 43e843e to 759d71f Compare August 17, 2026 08:58
@LesterEvSe

Copy link
Copy Markdown
Collaborator Author

In 763b2d8:

I think we should call the Error type "Uninhabited" (or "Never" if we want to be Rust-like), and similarly the is_error method should be is_uninhabited (or is_never or is_empty ... though I think is_empty would be confusing because it's such a common name in Rust).

Changed Error to Never and is_error to is_never in types.rs

In 8a1b03c:

Adds a blank line to witness.rs, otherwise doesn't touch the file.

I accidentally refactored the code while reviewing it. Deleted it.

@LesterEvSe
LesterEvSe force-pushed the feat/ast-multierrors branch from 4a26413 to 0d80370 Compare August 17, 2026 12:30
Comment thread src/types.rs
/// Nominal enum type, represented as a balanced sum of its variants'
/// payload types
Enum(EnumInfo),
/// Type of a recovered subtree. Compatible with every type; never re-reported.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In fdfae8b:

What is a "recovered subtree" what does it mean to "re-report" a type?

Comment thread src/value.rs
.collect::<arbitrary::Result<Vec<Self>>>()?;
Ok(Self::list(elements, ty.as_ref().clone(), *bound))
}
TypeInner::Never => unreachable!("cannot generate a value of a poisoned type"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In fdfae8b:

This one is not unreachable. We should return an Arbitrary error here indicating that there is no value of the never type.

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.

Refactor(ErrorHandler): Enhance error diagnostics for use item resolution Error recovery in analysis Implement error states in parser

2 participants