Skip to content

Commit

Permalink
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spec/compiler/parser/to_s_spec.cr
Original file line number Diff line number Diff line change
@@ -82,4 +82,8 @@ describe "ASTNode#to_s" do
expect_to_s "!a"
expect_to_s "!(1 < 2)"
expect_to_s "(1 + 2)..3"
expect_to_s "macro foo\n{{ @type }}\nend"
expect_to_s "macro foo\n\\{{ @type }}\nend"
expect_to_s "macro foo\n{% @type %}\nend"
expect_to_s "macro foo\n\\{%@type %}\nend"
end
4 changes: 4 additions & 0 deletions src/compiler/crystal/syntax/to_s.cr
Original file line number Diff line number Diff line change
@@ -753,6 +753,10 @@ module Crystal
end

def visit(node : MacroLiteral)
# These two can only come from an escaped sequence like \{ or \{%
if node.value == "{" || node.value.starts_with?("{%")
@str << "\\"
end
@str << node.value
false
end

0 comments on commit 91020b3

Please sign in to comment.