Skip to content

Commit 3d03439

Browse files
authored
Merge pull request #4399 from branai/shell-continuing-fix
Fix IndentationError works differently with cpython in interective shell
2 parents 4222b13 + 530a20c commit 3d03439

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

‎parser/src/error.rs‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,23 @@ pub(crate) fn parse_error_from_lalrpop(
205205
source_path,
206206
}
207207
}
208-
LalrpopError::UnrecognizedEOF { location, .. } => ParseError {
209-
error: ParseErrorType::Eof,
210-
location,
211-
source_path,
212-
},
208+
LalrpopError::UnrecognizedEOF { location, expected } => {
209+
// This could be an initial indentation error that we should ignore
210+
let indent_error = expected == ["Indent"];
211+
if indent_error {
212+
ParseError {
213+
error: ParseErrorType::Lexical(LexicalErrorType::IndentationError),
214+
location,
215+
source_path,
216+
}
217+
} else {
218+
ParseError {
219+
error: ParseErrorType::Eof,
220+
location,
221+
source_path,
222+
}
223+
}
224+
}
213225
}
214226
}
215227

0 commit comments

Comments
 (0)