Is there a built-in contract for verifying that, i...
# announcements
s
Is there a built-in contract for verifying that, if a Map contains key
k
then
Map[k]
is non-null? Or do I need to write my own?
Actually not sure this is really possible. Doesn’t seem like a contract can imply anything about other functions you can call on a parameter.
r
The current contract system in the compiler accepts simple boolean expression and set of specific contracts. AFAIK It’s not possible at the moment to add preconditions that are able to be set as data flow preconditions based on complex boolean expressions.
s
Which suggests that seems to be the case
r
Here is an example of roughly what you want to proof over List which is simple:
so essentially this kinds of proof requires more power than most compilers have. Unless its Idris or other langs where you can encode this refinements that make access safe.
k
The issue is that the key could have been removed on a different thread
👍 3