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

Commented Unassigned: NullReferenceException when running compiled code under mono [147]

$
0
0
I am running Dafny 1.9.6 on OS X using mono, and I've run into an issue when trying to run programs compiled by Dafny. For example, consider the following program Null.dfy

```
class Data {
}

method Main()
{
var a := new Data[10];
print (if a[7] == null then "null\n" else "not null\n");
}
```

When I compile this with `dafny Null.dfy` and then run `mono ./Null.exe`, I get a `NullReferenceException` and no other output.

I believe the issue is that `a[7] == null` is somehow getting compiled down into a method call on `a[7]`, which obviously won't work when it's null.

Am I missing something? Am I not supposed to use null in non-ghost contexts in Dafny?
Comments: I've attached the code generated by Dafny 1.9.6.21012. I also built the most recent revision (d954a409627e) from source and it looks like the bug has been fixed, perhaps by commit acd708f1f966. I think we can close this issue.

Viewing all articles
Browse latest Browse all 1106


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>