class Unimportant
end
abstract class Node
abstract def call # replace abstract declaration with the definition below and it works
# def call
# puts "YYY"
# [] of Unimportant
# end
end
class InnerNode(T) < Node
getter receiver : Node
def initialize(value : T, @receiver : Node)
end
def call
puts "InnerNode"
receiver.call
end
end
class EmptyNode < Node
def call
puts "EmptyNode"
end
end
# A
c = InnerNode.new(true, EmptyNode.new)
p c.call
# B
c = InnerNode.new(5, EmptyNode.new)
# C
InnerNode.new("string", EmptyNode.new)
# ERROR
v = 1.to_i64 # remove to_i64 and it works
c = InnerNode.new(true, InnerNode.new(v, EmptyNode.new))
c.call
Crashes with:
InnerNode
EmptyNode
nil
InnerNode
Invalid memory access (signal 11) at address 0x1a7bd60
[0x4509e5] *CallStack::print_backtrace:Int32 +117
[0x4450f6] __crystal_sigfault_handler +70
[0x7f56785fd390] ???
[0x1a7bd60] ???
Note:
1 to Int64Happens in:
On linux mint.
Might be related to #2665. Feel free to close this if this is not a separate issue.
Looks a lot like #3990, though you've managed to reduce it farther than I did. I'd love to know what's going on with this one.
Does not crashes anymore
$ crystal test.cr
InnerNode
EmptyNode
nil
InnerNode
InnerNode
EmptyNode
$ crystal --version
Crystal 0.31.1 (2019-10-02)
LLVM: 8.0.1
Default target: x86_64-apple-macosx
Most helpful comment
Does not crashes anymore