Replies: 2 comments 1 reply
-
Since the following could be ambiguous (is the var ghost or the entire sentence)
I think warnings should be issued too, depending on the context, of the form
|
Beta Was this translation helpful? Give feedback.
-
Would it always be possible to resolve the warnings you propose? I'm not sure I'm in favour of unresolvable warnings, since I don't know how a programmer would effectively use those. If you have unresolvable warnings then over time the list of warnings will grow and a programmer may end up ignoring all of them. As an alternative to a warning, using the IDE to render which expressions are erased at runtime could help as well. There's an issue for that feature here. |
Beta Was this translation helpful? Give feedback.
-
Currently, Dafny produces compileable output for method calls that are assigned to ghost variables. A Dafny statement
ghost var x := methodCall()
will be compiled to an invocation ofmethodCall
in the target language (the ghost variable will not be compiled).Compiling
methodCall
and not merely ignoring it is necessary if the method has a side effect; but pure methods are compiled, too, when assigned to ghost variables.Would it make sense to issue a warning for assignment statements that have ghost on the left-, and non-ghost method calls on the right-hand side?
For instance, in the following code:
the user might mistakenly think that the first call to
foo
would be ignored by the compiler, but the second call would be compiled. By contrast, the compiler will produce two calls tofoo
.Beta Was this translation helpful? Give feedback.
All reactions