sway icon indicating copy to clipboard operation
sway copied to clipboard

Add parser recovery for incomplete `let x = ` statement

Open Centril opened this issue 3 years ago • 0 comments

As per https://github.com/FuelLabs/sway/pull/2724#pullrequestreview-1104953282, we need to recover if the user wrote e.g., let x = but did not enter a following expression, or failed to terminate the statement with ;.

This probably needs some lexer tweaks, so that we can even do an enter_delimited. Otherwise, we'll not even attempt parsing the block. However, the lexer probably also lacks necessary info to do this intelligently, if we just attempt to recover for any unclosed delimiters. So we should let the parser know where recovery was made. See https://github.com/rust-lang/rust/blob/87788097b776f8e3662f76627944230684b671bd/compiler/rustc_parse/src/parser/diagnostics.rs#L2239-L2312 for some relevant code.

Centril avatar Sep 20 '22 20:09 Centril