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

Compiler bug with @id : Int32 = (@@id += 1) #9886

Open
I3oris opened this issue Nov 5, 2020 · 0 comments
Open

Compiler bug with @id : Int32 = (@@id += 1) #9886

I3oris opened this issue Nov 5, 2020 · 0 comments

Comments

@I3oris
Copy link
Contributor

I3oris commented Nov 5, 2020

Hello Crystal team!

I've found a bug when I write:

class Foo
  @@id = 0
  @id : Int32 = (@@id += 1)
end

Foo.new

This gives:

BUG: `@@id = @@id + 1` at /home/rwby/bug.cr:4:18 has no type (Exception)
  from ../../crystal/src/compiler/crystal/semantic/bindings.cr:13:18 in 'run_instance_vars_initializers'
  from ../../crystal/src/compiler/crystal/codegen/codegen.cr:1912:7 in 'allocate_aggregate'
  from ../../crystal/src/compiler/crystal/codegen/primitives.cr:702:5 in 'codegen_primitive_allocate'
  from ../../crystal/src/compiler/crystal/codegen/primitives.cr:27:15 in 'codegen_primitive'
  from ../../crystal/src/compiler/crystal/codegen/call.cr:419:7 in 'visit'
  from ../../crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from ../../crystal/src/compiler/crystal/codegen/codegen.cr:2188:9 in 'visit'
  from ../../crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from ../../crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in 'accept'
  from ../../crystal/src/compiler/crystal/codegen/codegen.cr:2193:7 in 'codegen_fun'
  from ../../crystal/src/compiler/crystal/codegen/fun.cr:51:3 in 'target_def_fun'
  from ../../crystal/src/compiler/crystal/codegen/call.cr:424:5 in 'visit'
  from ../../crystal/src/compiler/crystal/syntax/visitor.cr:27:12 in 'accept'
  from ../../crystal/src/compiler/crystal/codegen/codegen.cr:628:9 in 'accept'
  from ../../crystal/src/compiler/crystal/codegen/codegen.cr:2158:7 in 'codegen'
  from ../../crystal/src/compiler/crystal/compiler.cr:172:16 in 'compile'
  from ../../crystal/src/compiler/crystal/command.cr:209:5 in 'run_command'
  from ../../crystal/src/compiler/crystal/command.cr:62:5 in 'run'
  from ../../crystal/src/compiler/crystal.cr:11:1 in '__crystal_main'
  from ../../crystal/src/crystal/main.cr:105:5 in 'main'
  from src/env/__libc_start_main.c:94:2 in 'libc_start_main_stage2'
Error: you've found a bug in the Crystal compiler. Please open an issue, including source code that will allow us to reproduce the bug: https://github.com/crystal-lang/crystal/issues

This bug look a bit like #8802 in witch the discussion is interesting, I hope that issue will help you to handle problems with @@calss_vars.

Version :

Crystal 0.35.1 [5999ae29b] (2020-06-19)

LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants