contracts.ruby icon indicating copy to clipboard operation
contracts.ruby copied to clipboard

Using a pry console and calling load on a file that has already been loaded causes a ContractError

Open lardcanoe opened this issue 10 years ago • 2 comments

Is there a way to support this scenario? It's pretty common to debug in a pry console, which requires reloading the code file.

lardcanoe avatar Aug 06 '15 22:08 lardcanoe

Can you provide minimal example (push out small example class to repo or gist) with list of actions of how to reproduce the problem?

waterlink avatar Sep 04 '15 22:09 waterlink

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.

betamatt avatar Nov 07 '15 16:11 betamatt