Open
Description
Tested on 0.7. It's possible that module_function
is too magical to try to work around. In that case the docs should say not to use it. (It's probably not feasible to redefine module_function
to raise an error, because it might be called before including contracts.)
module OverloadCase
include Contracts
include Contracts::Modules
#extend self # this works
module_function # this doesn't
Contract 1 => 1
def fact(n) 1 end
Contract Integer => Integer
def fact(n)
n * fact(n-1)
end
end
module MinCase
include Contracts
include Contracts::Modules
#extend self # this works
module_function # this doesn't
Contract 1 => 1
def fact(n) 1 end
end
if __FILE__ == $0
p OverloadCase.fact(6) # => stack too deep
p MinCase.fact(6) # => violation is ignored, so 1 is returned
end