You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Error in foo.cr:13: instantiating 'Bar:Class#new()'
@@bar = Bar.new
^~~
instance variable '@baz' of Bar must be Int32, not Nil
Error: instance variable '@baz' is initialized inside a begin-rescue, so it can potentially be left uninitialized if an exception is raised and rescued
Note that however the code
classFoo@bar=Bar.new
end
pp Foo.new # => #<Foo:0x10b1c9f00 @bar=#<Bar:0x10b1cefd0 @baz=42>>
asterite
changed the title
Rescue in initialize can lead to uninitialized instance variables (take 2)
Instance var is incorrectly considered nil when class var initializer is involved
Feb 23, 2017
Given the following code for
Bar
The following code won't compile:
Note that however the code
does works as expected.
Might be related to #3706 , extracted from crystal-lang/crystal-mysql#22
The text was updated successfully, but these errors were encountered: