hokein wrote: > I kind of wonder if it would make sense for us to have a recovery function > that can be called consistently.
Thanks, that’s a fair point. I explored this further and believe that this inconsistency is a deliberate choice between different recovery strategies, each with its own trade-offs. Attempting to normalize these into a single strategy is a rabbit hole that causes various regressions. Summary of the two approaches: - SkipUntil Strategy: Used primarily in parsing member declarations. It handles simple typos well (e.g., `void foo() garbage;`) by treating misplaced tokens as noise and skipping to the next `;`. The trade-off is that valid code following a missing semicolon (e.g., `void foo() void bar();`) is discarded, which can break AST-based IDE features for the `bar()`. - Injection Strategy: This avoids the downsides of SkipUntil by attempting to parse and preserve tokens in the AST. However, if the misplaced tokens truly are "garbage," the parser may produce confusing secondary diagnostics, e.g. `declaration does not declare anything.` I think we have to stick with the status quo for now. Transitioning to a unified strategy would require an extensive exploration cycle far beyond the scope of this fix. https://github.com/llvm/llvm-project/pull/188123 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
