Distinguish MultipleStarArgs and InvalidStarArgs compile errors

This commit is contained in:
Jeong YunWon 2020-05-13 01:42:18 +09:00
parent 3f2b414fcc
commit a77e0b8587
2 changed files with 9 additions and 8 deletions

View file

@ -47,7 +47,9 @@ pub enum CompileErrorType {
Parse(ParseErrorType),
SyntaxError(String),
/// Multiple `*` detected
StarArgs,
MultipleStarArgs,
/// Misplaced `*` expression
InvalidStarExpr,
/// Break statement outside of loop.
InvalidBreak,
/// Continue statement outside of loop.
@ -97,7 +99,10 @@ impl fmt::Display for CompileError {
CompileErrorType::ExpectExpr => "Expecting expression, got statement".to_owned(),
CompileErrorType::Parse(err) => err.to_string(),
CompileErrorType::SyntaxError(err) => err.to_string(),
CompileErrorType::StarArgs => "Two starred expressions in assignment".to_owned(),
CompileErrorType::MultipleStarArgs => {
"two starred expressions in assignment".to_owned()
}
CompileErrorType::InvalidStarExpr => "can't use starred expression here".to_owned(),
CompileErrorType::InvalidBreak => "'break' outside loop".to_owned(),
CompileErrorType::InvalidContinue => "'continue' outside loop".to_owned(),
CompileErrorType::InvalidReturn => "'return' outside function".to_owned(),