Open zw963 opened 1 year ago
Just a note that it seems the compiler's message was telling you to put the declaration at the class level, like this:
class A
@x : Int32? # This is what the compiler was telling you
def initialize(x)
@x = x
end
end
Just a note that it seems the compiler's message was telling you to put the declaration at the class level, like this:
Yes, those message intention clear enough, the key point is, after i add || nil
, new error message override the class level one, i updated my issue content for clarify.
Original link: https://forum.crystal-lang.org/t/confusing-error-output-instance-variable-x-of-a-was-inferred-to-be-nil/5053
Following is code:
Okay, the output is expected, because i declare the type of @x wrong way.
Then, i change to this:
The key point of this issue is, the above two error message, which one is more important?
If we should show the first class scope error msg at first?
thanks