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

Crash when referencing class variable in instance variable initializer #6440

Open
Michionlion opened this issue Jul 24, 2018 · 1 comment
Open

Comments

@Michionlion
Copy link

When referencing a class variable in the assignment of an instance variable, the crystal compiler errors with BUG: @@next_id = @@next_id + 1 at /testing/test.cr:3:15 has no type (Exception). The code that produces this is below.

class IdHaver
  @@next_id : Int32 = 0
  @id : Int32 = @@next_id += 1
end

ider = IdHaver.new

I'm on openSUSE Leap 42.3, and the output of crystal -v is included below.

Crystal 0.25.1 [b782738ff] (2018-06-27)

LLVM: 4.0.0
Default target: x86_64-unknown-linux-gnu
@RX14
Copy link
Contributor

RX14 commented Jul 28, 2018

class Foo
  @@a = 0
  @@b = (@@a = 1)
end

ider = Foo.new

reduced

any assign in the initializer for an ivar or cvar to an ivar or cvar seems to be the issue

@asterite asterite changed the title Crystal compiler bug on referencing class variables Crash when referencing class variable in instance variable initializer Aug 27, 2018
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