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

Contracts confused by block with `Maybe`?

Open indigoviolet opened this issue 8 years ago • 2 comments

  class Bar
    include Contracts::Builtin
    include Contracts::Core

    Contract String, Maybe[Integer], Func[Any => Any] => Any
    def self.contract_foo(a, b=nil, &blk)
      puts [a, b, blk].to_json
    end
  end
[26] development (main)> Bar.contract_foo "a" do
[26] development (main)* end
ParamContractError: Contract violation for argument 2 of 2:
        Expected: (Integer or nil),
        Actual: #<Proc:0x0055dbc44fc388@(pry):31>

indigoviolet avatar Dec 12 '16 07:12 indigoviolet

See https://github.com/egonSchiele/contracts.ruby/pull/214

indigoviolet avatar Dec 12 '16 11:12 indigoviolet

I can reproduce

egonSchiele avatar Jan 17 '17 21:01 egonSchiele