Skip to content

Commit

Permalink
Fix to keep paren information for to_s on clone (crystal-lang#5454)
Browse files Browse the repository at this point in the history
Fixed crystal-lang#5415

Added keeping information for `to_s` on clone check in `compiler/parser/to_s_spec.cr`.
I think this property should be kept by all `ASTNode#clone` implementation.
  • Loading branch information
makenowjust authored and RX14 committed Jan 11, 2018
1 parent 048f77e commit f59a349
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion spec/compiler/parser/to_s_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ private def expect_to_s(original, expected = original, emit_doc = false, file =
str = IO::Memory.new expected.bytesize
parser = Parser.new original
parser.wants_doc = emit_doc
parser.parse.to_s(str, emit_doc: emit_doc)
node = parser.parse
node.to_s(str, emit_doc: emit_doc)
str.to_s.should eq(expected), file, line

# Check keeping information for `to_s` on clone
cloned = node.clone
str.clear
cloned.to_s(str, emit_doc: emit_doc)
str.to_s.should eq(expected), file, line
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/syntax/ast.cr
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ module Crystal
end

def clone_without_location
Expressions.new(@expressions.clone)
Expressions.new(@expressions.clone).tap &.keyword = keyword
end

def_equals_and_hash expressions
Expand Down

0 comments on commit f59a349

Please sign in to comment.