Skip to main content

without_lex_echoes

Function without_lex_echoes 

Source
pub fn without_lex_echoes(
    lex_errors: &[CompileError],
    tokens: &[Token],
    parse_errors: Vec<CompileError>,
) -> Vec<CompileError>
Expand description

#2807: parse_errors without the ones a lexical error caused. Recovery skips the text a lex error covers, so the parser meets a gap where the literal or character stood and complains about it at the same spot. An error that starts in a lex error’s span, or at the token right after it, is that echo and is dropped; every other syntax error stays. tokens is the recovering lex’s token list. A heuristic: a genuine syntax error at that next token (the fn after a stray character on its own line) is dropped with the echo, and surfaces once the lexical error is fixed.