Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: called llvm_struct_type for union of generics #5207

Closed
lbguilherme opened this issue Oct 29, 2017 · 0 comments
Closed

BUG: called llvm_struct_type for union of generics #5207

lbguilherme opened this issue Oct 29, 2017 · 0 comments
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:generics topic:compiler

Comments

@lbguilherme
Copy link
Contributor

class Foo(T)
  def initialize(@x : T)
  end
end

Foo(Int32).new(0)
Foo(Int64).new(0i64)
p instance_sizeof(Foo)

causes:

BUG: called llvm_struct_type for (Foo(Int32) | Foo(Int64))
.../src/compiler/crystal/codegen/llvm_typer.cr:410:7 in 'create_llvm_struct_type'
.../src/compiler/crystal/codegen/llvm_typer.cr:308:33 in 'llvm_struct_type'
.../src/compiler/crystal/codegen/llvm_typer.cr:302:5 in 'llvm_struct_type'
.../src/compiler/crystal/codegen/codegen.cr:83:26 in 'instance_size_of'
.../src/compiler/crystal/semantic/main_visitor.cr:2476:20 in 'visit'
.../src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
.../src/compiler/crystal/semantic/main_visitor.cr:1236:21 in 'visit'
.../src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
.../src/compiler/crystal/syntax/ast.cr:150:27 in 'accept_children'
.../src/compiler/crystal/syntax/visitor.cr:28:11 in 'accept'
.../src/compiler/crystal/semantic/main_visitor.cr:7:7 in 'visit_main'
.../src/compiler/crystal/semantic/main_visitor.cr:5:5 in 'visit_main:process_finished_hooks:cleanup'
.../src/compiler/crystal/semantic.cr:22:7 in 'semantic'
.../src/compiler/crystal/compiler.cr:141:7 in 'compile'
.../src/compiler/crystal/command.cr:265:7 in 'compile'
.../src/compiler/crystal/command.cr:184:14 in 'run_command'
.../src/compiler/crystal/command.cr:102:7 in 'run'
.../src/compiler/crystal/command.cr:49:5 in 'run'
.../src/compiler/crystal/command.cr:48:3 in 'run'
.../src/compiler/crystal.cr:8:1 in '__crystal_main'
.../src/crystal/main.cr:11:3 in '_crystal_main'
.../src/crystal/main.cr:112:5 in 'main_user_code'
.../src/crystal/main.cr:101:7 in 'main'
.../src/crystal/main.cr:135:3 in 'main'
__libc_start_main
_start
???

I don't see anything sane that could be returned from this instance_sizeof, so this should cause an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:compiler:generics topic:compiler
Projects
None yet
Development

No branches or pull requests

2 participants