test for crazy interpolation inside @if
This commit is contained in:
parent
0c0c154b66
commit
b42ae61435
@ -545,9 +545,8 @@ impl<'a> Parser<'a> {
|
||||
self.throw_away_until_closing_curly_brace()?;
|
||||
}
|
||||
|
||||
self.whitespace_or_comment();
|
||||
|
||||
loop {
|
||||
self.whitespace_or_comment();
|
||||
if let Some(Token { kind: '@', pos }) = self.toks.peek().cloned() {
|
||||
self.toks.peek_forward(1);
|
||||
let ident = peek_ident_no_interpolation(self.toks, false, pos)?;
|
||||
|
@ -27,10 +27,14 @@ impl<'a> Parser<'a> {
|
||||
return Err((format!("Expected {}.", q), tok.pos).into());
|
||||
}
|
||||
}
|
||||
'#' => {
|
||||
self.toks.next();
|
||||
self.throw_away_until_closing_curly_brace()?;
|
||||
}
|
||||
'#' => match self.toks.peek() {
|
||||
Some(Token { kind: '{', .. }) => {
|
||||
self.toks.next();
|
||||
self.throw_away_until_closing_curly_brace()?;
|
||||
}
|
||||
Some(..) => {}
|
||||
None => return Err(("expected \"{\".", self.span_before).into()),
|
||||
},
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
23
tests/if.rs
23
tests/if.rs
@ -140,6 +140,29 @@ test!(
|
||||
"@mixin foo {\n color: red;\n}\n\n@if true {\n a {\n @include foo;\n }\n}\n",
|
||||
"a {\n color: red;\n}\n"
|
||||
);
|
||||
test!(
|
||||
crazy_interpolation,
|
||||
"a {
|
||||
@if true {
|
||||
a: #{\"#{\"\\\\}}}{{{\"}#\"};
|
||||
}
|
||||
|
||||
@if false {
|
||||
a: #{\"#{\"\\\\}}}{{{\"}#\"};
|
||||
} @else if true {
|
||||
b: #{\"#{\"\\\\}}}{{{\"}#\"};
|
||||
}
|
||||
|
||||
@if false {
|
||||
a: #{\"#{\"\\\\}}}{{{\"}#\"};
|
||||
} @else if false {
|
||||
b: #{\"#{\"\\\\}}}{{{\"}#\"};
|
||||
} @else {
|
||||
c: #{\"#{\"\\\\}}}{{{\"}#\"};
|
||||
}
|
||||
}",
|
||||
"a {\n a: \\}}}{{{#;\n b: \\}}}{{{#;\n c: \\}}}{{{#;\n}\n"
|
||||
);
|
||||
error!(
|
||||
nothing_after_escape,
|
||||
"@if \\", "Error: Expected expression."
|
||||
|
Loading…
x
Reference in New Issue
Block a user