contracts.ruby
contracts.ruby copied to clipboard
Using a pry console and calling load on a file that has already been loaded causes a ContractError
Is there a way to support this scenario? It's pretty common to debug in a pry console, which requires reloading the code file.
Can you provide minimal example (push out small example class to repo or gist) with list of actions of how to reproduce the problem?
This also appears to be an issue with Rails code reloading when using multi-methods. Only the final version of the method ends up being valid.
Ex:
class Model
Contract Int => Int
def add(i)
i + 1
end
Contract nil => nil
def add(i)
nil
end
end
After reloading, calling add(1) would fail with a contract violation because it's only expecting nil as an argument.