mirror of
https://github.com/casey/just.git
synced 2024-11-24 04:38:25 +03:00
Make EOL after interpolation a proper error (#279)
This commit is contained in:
parent
661342bb11
commit
9a56e27e18
@ -37,6 +37,7 @@ pub enum CompilationErrorKind<'a> {
|
||||
UnknownDependency{recipe: &'a str, unknown: &'a str},
|
||||
UnknownFunction{function: &'a str},
|
||||
UnknownStartOfToken,
|
||||
UnterminatedInterpolation,
|
||||
UnterminatedString,
|
||||
}
|
||||
|
||||
@ -130,6 +131,9 @@ impl<'a> Display for CompilationError<'a> {
|
||||
UnknownStartOfToken => {
|
||||
writeln!(f, "Unknown start of token:")?;
|
||||
}
|
||||
UnterminatedInterpolation => {
|
||||
writeln!(f, "Unterminated interpolation")?;
|
||||
}
|
||||
UnterminatedString => {
|
||||
writeln!(f, "Unterminated string")?;
|
||||
}
|
||||
|
15
src/lexer.rs
15
src/lexer.rs
@ -200,9 +200,7 @@ impl<'a> Lexer<'a> {
|
||||
(captures.get(1).unwrap().as_str(), captures.get(2).unwrap().as_str(), Name)
|
||||
} else if let Some(captures) = EOL.captures(self.rest) {
|
||||
if self.state.last().unwrap() == &State::Interpolation {
|
||||
return Err(self.error(Internal {
|
||||
message: "hit EOL while still in interpolation state".to_string()
|
||||
}));
|
||||
return Err(self.error(UnterminatedInterpolation));
|
||||
}
|
||||
(captures.get(1).unwrap().as_str(), captures.get(2).unwrap().as_str(), Eol)
|
||||
} else if let Some(captures) = BACKTICK.captures(self.rest) {
|
||||
@ -602,6 +600,17 @@ c: b
|
||||
kind: UnterminatedString,
|
||||
}
|
||||
|
||||
error_test! {
|
||||
name: unterminated_interpolation,
|
||||
input: "foo:\n echo {{
|
||||
",
|
||||
index: 13,
|
||||
line: 1,
|
||||
column: 8,
|
||||
width: None,
|
||||
kind: UnterminatedInterpolation,
|
||||
}
|
||||
|
||||
error_test! {
|
||||
name: mixed_leading_whitespace,
|
||||
input: "a:\n\t echo hello",
|
||||
|
Loading…
Reference in New Issue
Block a user