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.throw_away_until_closing_curly_brace()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.whitespace_or_comment();
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
self.whitespace_or_comment();
|
||||||
if let Some(Token { kind: '@', pos }) = self.toks.peek().cloned() {
|
if let Some(Token { kind: '@', pos }) = self.toks.peek().cloned() {
|
||||||
self.toks.peek_forward(1);
|
self.toks.peek_forward(1);
|
||||||
let ident = peek_ident_no_interpolation(self.toks, false, pos)?;
|
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());
|
return Err((format!("Expected {}.", q), tok.pos).into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'#' => {
|
'#' => match self.toks.peek() {
|
||||||
self.toks.next();
|
Some(Token { kind: '{', .. }) => {
|
||||||
self.throw_away_until_closing_curly_brace()?;
|
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",
|
"@mixin foo {\n color: red;\n}\n\n@if true {\n a {\n @include foo;\n }\n}\n",
|
||||||
"a {\n color: red;\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!(
|
error!(
|
||||||
nothing_after_escape,
|
nothing_after_escape,
|
||||||
"@if \\", "Error: Expected expression."
|
"@if \\", "Error: Expected expression."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user