Quantcast
Channel: Dafny: An Automatic Program Verifier for Functional Correctness
Viewing all articles
Browse latest Browse all 1106

Commented Unassigned: reads clause fails to recognize previous requires clause. [51]

$
0
0
The following code [fails to compile](http://rise4fun.com/Dafny/Gplys):
```
class Foo
{
var bar:object;
}

predicate MyPredicate(foo:Foo)
requires foo != null;
reads foo;
requires foo.bar != null;
reads foo.bar;
{
true
}
```
It seems that the __requires__ clause should ensure that the __reads__ clause is confident that _foo.bar_ cannot be __null__.

A workaround that currently works is to use the following expression in the __reads__ clause:

```
reads if foo != null then {foo.bar} else {}
```

Thanks!
Comments: Bryan Parno has informed me that this behavior is by design and not a bug. My apologies for the false alarm. ~mlr

Viewing all articles
Browse latest Browse all 1106

Trending Articles