You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parser: prevent to finish a macro body when {% if/for/begin %} is nested (#4801)
Fixed#4769
This introduced `control_nest` counter variable to keep macro control
(if/for/begin) nesting information. When the parser find `end` inside
macro body, it checks `control_nest` and finishes a macro body if and
only if `control_nest` is `0` (and `nest` which is usual block nesting
information is `0` also).
And formatter is fixed also.
Copy file name to clipboardExpand all lines: spec/compiler/parser/parser_spec.cr
+1
Original file line number
Diff line number
Diff line change
@@ -770,6 +770,7 @@ describe "Parser" do
770
770
771
771
it_parses "{% for x in y %}body{% end %}", MacroFor.new(["x".var], "y".var, "body".macro_literal)
772
772
it_parses "{% if x %}body{% end %}", MacroIf.new("x".var, "body".macro_literal)
773
+
it_parses "{% begin %}{% if true %}if true{% end %}\n{% if true %}end{% end %}{% end %}", MacroIf.new(true.bool, [MacroIf.new(true.bool, "if true".macro_literal), "\n".macro_literal, MacroIf.new(true.bool, "end".macro_literal)] of ASTNode)
0 commit comments