-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An example in Language manual, a strange type error occurred. #688
Comments
It looks like this is because the cases statement in the operation does not
have an 'others' clause? Though I agree that the existing cases do cover
all possibilities.
Can you try adding an others clause to see whether it changes the error -
I'm away again at the moment, so can't try it.
|
I think that "others statement" is optional in VDM10_lang_man and VDMTools's langmanpp_a4E.
|
Yes, others is optional. I'm trying to remotely investigate the issue, not
propose a solution.
Does VDMTools analyse cases patterns to determine when a cases statement
can possibly drop through? I think that VDMJ is incorrectly assuming that
this can happen in your example, even though the patterns cover all
possibilities.
A few experiments with various patterns and an 'other' clause would help.
|
In following example,
In following example,
|
OK, thanks Shin. It looks like VDMTools doesn't regard *possible* errors as
actual type errors here - def-checking picks it up instead.
VDMJ tries to report these as errors, but fails to see that s1^s2 is
guaranteed to match, and hence should not raise an error here.
We have had several "bugs" before about whether *possible* void paths in an
operation are errors or not. Currently they are treated as errors by VDMJ;
it seems they are only errors in VDMTools with def semantics.
I should be able to tighten the check regarding patterns that match any
value.
|
I've now changed VDMJ to determine whether any of the patterns in a cases statement will definitely match a value of the type passed to the statement. If (at least) one of the cases always matches, it has the same effect as an "others" clause - that is, suppressing the drop-through behaviour that could return a void value. So for example:
This raises an error because the statement can return no value (assuming the operation is ==> seq of nat). If you comment-in the extra case, which is guaranteed to match any sequence (even [] matches a^b, though that is caught earlier anyway), then there is no type error because there is no void path. It will take me a little longer to move the changes over to Overture... |
Fix now available in ncb/development. |
Just pushed a correction - Overture/VDMJ wasn't matching [] and {} with the concatenation and union patterns. Now it does (as VDMTools does). This is important here, otherwise (say) "a ^ b" wouldn't match any value of a sequence type, only non-empty sequences. |
Description
There is a strange type error in the merge sort example.
in the Language manual(Feb 2018, version 11, version of Overture .exe 2.6.0) p.57-58.
The example is following:
MergeSort.vdmpp.zip
Steps to Reproduce
Expected behavior:
There is no error.
Actual behavior:
Following type error occurred at line 4:
"Operation returns void value. Actual: (() | [] | seq of (nat)) Expected: seq of (nat) "
Reproduces how often:
every time.
Versions
Which version of Overture are you using?
Also, please include the OS and what version of the OS you're running.
Additional Information
On VDMTools, there is no error, and can get the result as following:
The text was updated successfully, but these errors were encountered: