Skip to content

Commit

Permalink
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
@@ -414,6 +414,7 @@ describe Crystal::Formatter do
assert_format "$1.bar", "$1.bar"
assert_format "$0", "$0"
assert_format "$0.bar", "$0.bar"
assert_format "$1?"

assert_format "foo . is_a? ( Bar )", "foo.is_a?(Bar)"
assert_format "foo . responds_to?( :bar )", "foo.responds_to?(:bar)"
2 changes: 1 addition & 1 deletion src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
@@ -2061,7 +2061,7 @@ module Crystal
column = @column

# Special case: $1, $2, ...
if @token.type == :GLOBAL_MATCH_DATA_INDEX && node.name == "[]" && obj.is_a?(Global)
if @token.type == :GLOBAL_MATCH_DATA_INDEX && (node.name == "[]" || node.name == "[]?") && obj.is_a?(Global)
write "$"
write @token.value
next_token

0 comments on commit 6027a94

Please sign in to comment.