1
1
mirror of https://github.com/tweag/nickel.git synced 2024-11-10 10:46:49 +03:00

Merge pull request #231 from tweag/fix/hash-in-multiline-strings

[Fix]Mishandling of `#` in mutliline strings
This commit is contained in:
Eelco Dolstra 2020-12-01 11:45:06 +01:00 committed by GitHub
commit edb90e6fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -278,7 +278,7 @@ pub enum MultiStringToken<'input> {
#[regex("\"#+m")]
CandidateEnd(&'input str),
// Same as `FalseEnd` and `CandidateEnd` but for an interpolation sequence.
#[token("#+")]
#[regex("#+")]
FalseInterpolation(&'input str),
#[regex("#+\\{")]
CandidateInterpolation(&'input str),

View File

@ -281,3 +281,16 @@ fn str_escape() {
mk_single_chunk("#a#b#c#{d#"),
);
}
/// Regression test for [#230](https://github.com/tweag/nickel/issues/230).
#[test]
fn multiline_str_escape() {
assert_eq!(
parse_without_pos(r##"m#"#Hel##lo###"#m"##),
mk_single_chunk("#Hel##lo###"),
);
assert_eq!(
parse_without_pos(r##"m#"#Hel##{lo###{"#m"##),
mk_single_chunk("#Hel##{lo###{"),
);
}