Fix panic with unterminated interpolated string.
This commit is contained in:
parent
40fda5139d
commit
6b4553ffc8
@ -1039,6 +1039,9 @@ fn parse_primary(
|
|||||||
segments.push(Expr::StringConstant(s.into(), pos));
|
segments.push(Expr::StringConstant(s.into(), pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
(Token::LexError(err @ LexError::UnterminatedString), pos) => {
|
||||||
|
return Err(err.into_err(pos))
|
||||||
|
}
|
||||||
(token, _) => unreachable!(
|
(token, _) => unreachable!(
|
||||||
"expected a string within an interpolated string literal, but gets {:?}",
|
"expected a string within an interpolated string literal, but gets {:?}",
|
||||||
token
|
token
|
||||||
|
12
src/token.rs
12
src/token.rs
@ -871,6 +871,18 @@ pub trait InputStream {
|
|||||||
/// # Volatile API
|
/// # Volatile API
|
||||||
///
|
///
|
||||||
/// This function is volatile and may change.
|
/// This function is volatile and may change.
|
||||||
|
///
|
||||||
|
/// # Returns
|
||||||
|
///
|
||||||
|
/// |Type |Return Value |`state.is_within_text_terminated_by`|
|
||||||
|
/// |---------------------------------|----------------------------|------------------------------------|
|
||||||
|
/// |`"hello"` |`StringConstant("hello")` |`None` |
|
||||||
|
/// |`"hello`_{LF}_ or _{EOF}_ |`LexError` |`None` |
|
||||||
|
/// |`"hello\`_{EOF}_ or _{LF}{EOF}_ |`StringConstant("hello")` |`Some('"')` |
|
||||||
|
/// |`` `hello``_{EOF}_ |`StringConstant("hello")` |``Some('`')`` |
|
||||||
|
/// |`` `hello``_{LF}{EOF}_ |`StringConstant("hello\n")` |``Some('`')`` |
|
||||||
|
/// |`` `hello ${`` |`InterpolatedString("hello ")`<br/>next token is `{`|`None` |
|
||||||
|
/// |`` } hello` `` |`StringConstant(" hello")` |``Some('`')`` |
|
||||||
pub fn parse_string_literal(
|
pub fn parse_string_literal(
|
||||||
stream: &mut impl InputStream,
|
stream: &mut impl InputStream,
|
||||||
state: &mut TokenizeState,
|
state: &mut TokenizeState,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user