lib/steep/ast/location.rb in steep-0.5.1 vs lib/steep/ast/location.rb in steep-0.6.0
- old
+ new
@@ -57,14 +57,18 @@
other.start_pos == start_pos &&
other.end_pos == end_pos
end
def +(other)
- raise "Invalid concat: buffer=#{buffer.name}, other.buffer=#{other.buffer.name}" unless other.buffer == buffer
+ if other
+ raise "Invalid concat: buffer=#{buffer.name}, other.buffer=#{other.buffer.name}" unless other.buffer == buffer
- self.class.new(buffer: buffer,
- start_pos: start_pos,
- end_pos: other.end_pos)
+ self.class.new(buffer: buffer,
+ start_pos: start_pos,
+ end_pos: other.end_pos)
+ else
+ self
+ end
end
def self.concat(*locations)
locations.inject {|l1, l2|
l1 + l2