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

Calling class method from class initializer #455

Open
yhara opened this issue Jan 22, 2023 · 0 comments
Open

Calling class method from class initializer #455

yhara opened this issue Jan 22, 2023 · 0 comments

Comments

@yhara
Copy link
Collaborator

yhara commented Jan 22, 2023

Given

class A
  def self.initialize
    A.foo
  end
  def self.foo
    ...
  end
end

This is safe if foo does not access an class instance variable of A.

Got

Compiler generates a binary but it results in SEGV.

Reason

  1. @init_A is called
  2. It tries to call @Meta_A_foo
  3. To do that, it refers the constant A to pass it as the first argument
  4. However, the constant A is null

To fix this

Refactor gen_const_inits and gen_class_literal into gen_class_constants or something.

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

1 participant