Implement AST multi-error recovery - #383
Conversation
ad880be to
a378398
Compare
5b353a1 to
fdd2abb
Compare
fdd2abb to
5202cc8
Compare
|
In 763b2d8: I think we should call the 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. |
4e826ec to
43e843e
Compare
43e843e to
759d71f
Compare
Changed
I accidentally refactored the code while reviewing it. Deleted it. |
759d71f to
08cf35a
Compare
08cf35a to
4a26413
Compare
4a26413 to
0d80370
Compare
| /// 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. |
There was a problem hiding this comment.
In fdfae8b:
What is a "recovered subtree" what does it mean to "re-report" a type?
| .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"), |
There was a problem hiding this comment.
In fdfae8b:
This one is not unreachable. We should return an Arbitrary error here indicating that there is no value of the never type.
There was a problem hiding this comment.
Agreed with @KyrylR that this PR is too large to review as one unit. I'm splitting it into a sequence:
(Rough split, not yet validated)
- Add the uninhabited
Nevertype toTypeInner(+is_never,
ResolvedType::compatible, and theArbitraryimpl returning an error
instead ofunreachable!). Standalone and useful on its own. Errorvariants in the parse tree + parser recovery (Implement error states in parser #205).- Diagnostics sink in
Scope; containers collect instead of aborting (Error recovery in analysis #207). - Split
parse_from_str/parse_from_contentby error policy.
@apoelstra, I plan to address your comment about the Arbitrary branch in (1). I'll also rewrite the doc comment "recovered subtree" and "re-report" are not defined anywhere. Sorry for the churn.
Keeping this open as a draft for the overall design; I'll close it once (4)
is merged.
Analysis now reports every independent error in one pass instead of stopping at
the first.
Errorvariants in the parse tree, AST, and typesystem (
TypeInner::Error); recovery emits these instead of fabricated units,aliases, or sizes.
is_errorguardsand
ResolvedType::compatible), so one broken construct does not spawn secondaryerrors.
Scopecarries a diagnostics sink; containers recordan error and keep analyzing siblings, and
Program::analyzereturnsOption.parse_from_str(fragments, first error) vsparse_from_content(files, collect all), over one shared core.