3 ms·
I think it's maybe less global than it was previously (and in a way that helps pave the way for improving compile times), but there's still a lot of ways to cau
by abhorrence 7y ago
I think it's maybe less global than it was previously (and in a way that helps pave the way for improving compile times), but there's still a lot of ways to cause spooky type errors at a distance due to the assignment type inference rule.
module Example
def self.some_method
"string"
end
class Foo
getter :var1
def initialize
@var1 = SomeUtilities.something
end
end
module SomeUtilities
def self.something
Example.some_method
end
def self.do_something_with_string(input : String)
puts input
end
end
end
Example::SomeUtilities.do_something_with_string(Example::Foo.new)
If you change Example.some_method to return :symbol, you now get a type error on the final line.
- yxhuvud 7y agoI like that behaviour. Normally you don't get to pay the overhead of having to spell it out but it is a nice tool to have, being able to gradually add type information to fence in errors.