mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Fix handling of 'unless' or 'case' nested in if/else
The parser checks for incorrect 'else' nesting by tracking if/case/unless blocks in an internal stack. It was pushing to but never popping from this stack for 'unless' and 'case' blocks, leading to spurious syntax errors. Regression examples included.
This commit is contained in:
parent
8fb5a12659
commit
9579e26218
2 changed files with 6 additions and 1 deletions
|
@ -444,7 +444,7 @@ module Haml
|
|||
end
|
||||
|
||||
def close_silent_script(node)
|
||||
@script_level_stack.pop if node.value[:keyword] == "if"
|
||||
@script_level_stack.pop if ["if", "case", "unless"].include? node.value[:keyword]
|
||||
|
||||
# Post-process case statements to normalize the nesting of "when" clauses
|
||||
return unless node.value[:keyword] == "case"
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
Odd!
|
||||
- else
|
||||
Even!
|
||||
- unless true
|
||||
Testing else indent
|
||||
- case 1
|
||||
- when 2
|
||||
Also testing else indent
|
||||
- else
|
||||
= "This can't happen!"
|
||||
- 13 |
|
||||
|
|
Loading…
Reference in a new issue