You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The KeywordArgs contract appears to have two deficiencies:
A missing arg with a Maybe[] contract is valid despite not being declared optional
[9] development (main)> kk = Contracts::KeywordArgs[a: Contracts::Maybe[String]]
[10] development (main)> kk.valid?({})
=> true
In practice, this is often not an issue because the function definition would be like
Contract Contracts::KeywordArgs[a: Contracts::Maybe[String]]
def foo(a: )
end
and Ruby would enforce the presence of a.
However this would break in the more esoteric case of
Contract Contracts::KeywordArgs[a: Contracts::Maybe[String]]
def foo(**kwargs)
end
Default values for optional args are not validated by Contracts
[6] development (main)> module Foo
[6] development (main)* Contract KeywordArgs[a: Optional[String]] => Any
[6] development (main)* def self.foo(a: 2)
[6] development (main)* end
[6] development (main)* end
[7] development (main)> Foo.foo
=> nil
The text was updated successfully, but these errors were encountered:
The KeywordArgs contract appears to have two deficiencies:
Maybe[]
contract is valid despite not being declared optionalIn practice, this is often not an issue because the function definition would be like
and Ruby would enforce the presence of
a
.However this would break in the more esoteric case of
The text was updated successfully, but these errors were encountered: