mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Fix parsing crash with dollar escapes
This commit is contained in:
parent
89a64fed74
commit
e47d7924d3
4 changed files with 8 additions and 0 deletions
|
@ -181,6 +181,7 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri
|
|||
|
||||
match one_byte {
|
||||
b'"' if !is_single_quote => {
|
||||
preceded_by_dollar = false;
|
||||
if segment_parsed_bytes == 1 && segments.is_empty() {
|
||||
// special case of the empty string
|
||||
if is_multiline {
|
||||
|
@ -252,6 +253,7 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri
|
|||
};
|
||||
}
|
||||
b'\'' if is_single_quote => {
|
||||
preceded_by_dollar = false;
|
||||
end_segment!(StrSegment::Plaintext);
|
||||
|
||||
let expr = if segments.len() == 1 {
|
||||
|
@ -318,6 +320,7 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri
|
|||
));
|
||||
}
|
||||
b'\n' => {
|
||||
preceded_by_dollar = false;
|
||||
if is_multiline {
|
||||
let without_newline = &state.bytes()[0..(segment_parsed_bytes - 1)];
|
||||
let with_newline = &state.bytes()[0..segment_parsed_bytes];
|
||||
|
@ -352,6 +355,7 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri
|
|||
}
|
||||
}
|
||||
b'\\' => {
|
||||
preceded_by_dollar = false;
|
||||
// We're about to begin an escaped segment of some sort!
|
||||
//
|
||||
// Record the current segment so we can begin a new one.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue