Skip to content

Commit

Permalink
Merge pull request #4399 from branai/shell-continuing-fix
Browse files Browse the repository at this point in the history
Fix IndentationError works differently with cpython in interective shell
  • Loading branch information
youknowone authored Jan 2, 2023
2 parents 4222b13 + 530a20c commit 3d03439
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions parser/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,23 @@ pub(crate) fn parse_error_from_lalrpop(
source_path,
}
}
LalrpopError::UnrecognizedEOF { location, .. } => ParseError {
error: ParseErrorType::Eof,
location,
source_path,
},
LalrpopError::UnrecognizedEOF { location, expected } => {
// This could be an initial indentation error that we should ignore
let indent_error = expected == ["Indent"];
if indent_error {
ParseError {
error: ParseErrorType::Lexical(LexicalErrorType::IndentationError),
location,
source_path,
}
} else {
ParseError {
error: ParseErrorType::Eof,
location,
source_path,
}
}
}
}
}

Expand Down

0 comments on commit 3d03439

Please sign in to comment.