Created
December 14, 2016 01:50
-
-
Save gsinclair/39d848df1439ba86c02355a0376fa51f to your computer and use it in GitHub Desktop.
A problem I'm having setting a contract on a class-level method. The problem may be related to that or to something else.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I know class-method contracts have been discussed (and fixed -- #7 ) before, but I have occasional problems with contracts on class methods. Here is the latest one, for example. | |
#<ParamContractError: Contract violation for argument 3 of 3: | |
Expected: nil, | |
Actual: #<Proc:0x80354744@.../lib/scm_roster/report/roster.rb:19> | |
Value guarded in: SCMRoster::Report::Util::process_data_and_notify_change | |
With Contract: Module, Func => None | |
At: .../lib/scm_roster/report/util.rb:22 > | |
[I have snipped the paths for readability.] | |
Here is the calling code: | |
Report::Util.process_data_and_notify_change( | |
roster_report_infos, | |
-> x { x.task.date.month} ) do |rri, change| | |
out.puts() if change | |
out.puts csv_line(rri) | |
end | |
And here is the implementing code: | |
Contract Enumerable, Func[Any => Any] => None | |
def Util.process_data_and_notify_change(data, fn) | |
... | |
yield [item, changed] | |
... | |
end | |
Now here is what I don't get: why is there a contract violation on argument 3 of 3 when there are only two arguments to the method??? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment