Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indentation of Select nodes' macro interpolation #14510

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions spec/compiler/parser/to_s_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,22 @@ describe "ASTNode#to_s" do
expect_to_s "def foo(x)\n yield\nend", "def foo(x, &)\n yield\nend"
expect_to_s "def foo(**x)\n yield\nend", "def foo(**x, &)\n yield\nend"
expect_to_s "macro foo(x)\n yield\nend"
expect_to_s <<-CRYSTAL
select
when foo
select
when bar
1
else
2
end
else
select
when baz
3
else
4
end
end
CRYSTAL
end
4 changes: 3 additions & 1 deletion src/compiler/crystal/syntax/to_s.cr
Original file line number Diff line number Diff line change
Expand Up @@ -1373,18 +1373,20 @@ module Crystal
@str << "select"
newline
node.whens.each do |a_when|
append_indent
@str << "when "
a_when.condition.accept self
newline
accept_with_indent a_when.body
end
if a_else = node.else
append_indent
@str << "else"
newline
accept_with_indent a_else
end
append_indent
@str << "end"
newline
false
end

Expand Down
Loading