shiika
shiika copied to clipboard
Calling class method from class initializer
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
-
@init_A
is called - It tries to call
@Meta_A_foo
- To do that, it refers the constant
A
to pass it as the first argument - However, the constant
A
is null
To fix this
Refactor gen_const_inits
and gen_class_literal
into gen_class_constants
or something.