Open proxima opened 6 years ago
Reduced:
# Must be generic
abstract class Foo(T)
def method
method_impl # The call is important
end
end
# Makes no difference
#class Bar(T) < Foo(T)
# def method_impl
# end
#end
class Test
@var : Foo(Int32)? = nil
def method
@var.try &.method
end
end
Test.new.method
No idea what's going on though..
Debug backtrace:
BUG: `` at has no type (Exception)
from src/compiler/crystal/semantic/bindings.cr:13:45 in 'type'
from src/compiler/crystal/codegen/call.cr:453:15 in 'inline_call_return_value'
from src/compiler/crystal/codegen/call.cr:428:7 in 'try_inline_call'
from src/compiler/crystal/codegen/call.cr:394:8 in 'codegen_call'
from src/compiler/crystal/codegen/call.cr:35:7 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2074:7 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:68:5 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2074:7 in 'accept'
from src/compiler/crystal/codegen/call.cr:286:13 in 'codegen_call_with_block'
from src/compiler/crystal/codegen/call.cr:32:9 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2074:7 in 'accept'
from src/compiler/crystal/codegen/call.cr:378:11 in 'codegen_dispatch'
from src/compiler/crystal/codegen/call.cr:15:7 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2074:7 in 'accept'
from src/compiler/crystal/codegen/fun.cr:144:9 in 'codegen_fun'
from src/compiler/crystal/codegen/fun.cr:51:3 in 'codegen_fun'
from src/compiler/crystal/codegen/fun.cr:8:54 in 'target_def_fun'
from src/compiler/crystal/codegen/call.cr:408:12 in 'codegen_call'
from src/compiler/crystal/codegen/call.cr:35:7 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2074:7 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:605:9 in 'visit'
from src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:2074:7 in 'accept'
from src/compiler/crystal/codegen/codegen.cr:65:7 in 'codegen'
from src/compiler/crystal/codegen/codegen.cr:63:5 in 'codegen:debug:single_module'
from src/compiler/crystal/compiler.cr:22:7 in 'codegen'
from src/compiler/crystal/compiler.cr:153:16 in 'compile'
@bcardiff This doesn't seem to be related to generics. In fact, the error is the same with a non-generic type.
I suppose it has to do with there being no valid concrete ancestor of Foo
and #method
doesn't seem to be semantically analysed and it only fails at codegen.
You are probably right, it's just that all the examples so far were with generics...
Yep. @bew stated it needed to be generic, but it doesn't.
Maybe related: #6996
Commenting out the line
c.receive
makes the compiler not complain.