[m-rev.] diff: better messages for malformed if-then-elses

Zoltan Somogyi zoltan.somogyi at runbox.com
Fri Nov 27 22:49:41 AEDT 2015


For the test case added by this diff, the compiler now generates

malformed_ite.m:019: Error: no clauses for predicate `p'/2.
malformed_ite.m:027: Error: malformed if-then-else; this `then' is missing its
malformed_ite.m:027:   `if'.
malformed_ite.m:035: Error: malformed if-then-else; replace the `->' with
malformed_ite.m:035:   `then'.
malformed_ite.m:045: Error: malformed if-then-else; replace the `;' with
malformed_ite.m:045:   `else'.
malformed_ite.m:051: Error: malformed if-then-else; replace the `->' with
malformed_ite.m:051:   `then', and add an `if' before the condition.
malformed_ite.m:061: Error: malformed if-then-else; replace the `;' with
malformed_ite.m:061:   `else'.
malformed_ite.m:067: Error: malformed if-then-else; this `if' has no `then'.

which is 12 lines. It used to generate the following, much more
confusing 96 lines:

malformed_ite.m:027: In clause for predicate `p'/2:
malformed_ite.m:027:   in argument 1 of call to predicate `else'/2:
malformed_ite.m:027:   error: `then' without `if' or `else'.
malformed_ite.m:028: In clause for predicate `p'/2:
malformed_ite.m:028:   in argument 1 of call to predicate `else'/2:
malformed_ite.m:028:   in argument 2 of functor `then/2':
malformed_ite.m:028:   error: the language construct `='/2 should be used as a
malformed_ite.m:028:   goal, not as an expression.
malformed_ite.m:029: In clause for predicate `p'/2:
malformed_ite.m:029:   error: unmatched `else'.
malformed_ite.m:030: In clause for predicate `p'/2:
malformed_ite.m:030:   in argument 2 of call to predicate `else'/2:
malformed_ite.m:030:   error: the language construct `='/2 should be used as a
malformed_ite.m:030:   goal, not as an expression.
malformed_ite.m:035: In clause for predicate `p'/2:
malformed_ite.m:035:   in argument 1 of call to predicate `else'/2:
malformed_ite.m:035:   error: undefined symbol `if'/1.
malformed_ite.m:035: In clause for predicate `p'/2:
malformed_ite.m:035:   in argument 1 of call to predicate `else'/2:
malformed_ite.m:035:   in argument 1 of functor `if/1':
malformed_ite.m:035:   error: `->' without `;'.
malformed_ite.m:036: In clause for predicate `p'/2:
malformed_ite.m:036:   in argument 1 of call to predicate `else'/2:
malformed_ite.m:036:   in argument 1 of functor `if/1':
malformed_ite.m:036:   in argument 2 of functor `->/2':
malformed_ite.m:036:   error: the language construct `='/2 should be used as a
malformed_ite.m:036:   goal, not as an expression.
malformed_ite.m:037: In clause for predicate `p'/2:
malformed_ite.m:037:   error: unmatched `else'.
malformed_ite.m:038: In clause for predicate `p'/2:
malformed_ite.m:038:   in argument 2 of call to predicate `else'/2:
malformed_ite.m:038:   error: the language construct `='/2 should be used as a
malformed_ite.m:038:   goal, not as an expression.
malformed_ite.m:043: In clause for predicate `p'/2:
malformed_ite.m:043:   error: undefined predicate `if'/1.
malformed_ite.m:043: In clause for predicate `p'/2:
malformed_ite.m:043:   in argument 1 of call to predicate `if'/1:
malformed_ite.m:043:   error: `then' without `if' or `else'.
malformed_ite.m:044: In clause for predicate `p'/2:
malformed_ite.m:044:   in argument 1 of call to predicate `if'/1:
malformed_ite.m:044:   in argument 2 of functor `then/2':
malformed_ite.m:044:   in argument 1 of functor `;/2':
malformed_ite.m:044:   error: the language construct `='/2 should be used as a
malformed_ite.m:044:   goal, not as an expression.
malformed_ite.m:045: In clause for predicate `p'/2:
malformed_ite.m:045:   in argument 1 of call to predicate `if'/1:
malformed_ite.m:045:   in argument 2 of functor `then/2':
malformed_ite.m:045:   error: the language construct `;'/2 should be used as a
malformed_ite.m:045:   goal, not as an expression.
malformed_ite.m:046: In clause for predicate `p'/2:
malformed_ite.m:046:   in argument 1 of call to predicate `if'/1:
malformed_ite.m:046:   in argument 2 of functor `then/2':
malformed_ite.m:046:   in argument 2 of functor `;/2':
malformed_ite.m:046:   error: the language construct `='/2 should be used as a
malformed_ite.m:046:   goal, not as an expression.
malformed_ite.m:051: In clause for predicate `p'/2:
malformed_ite.m:051:   in argument 1 of call to predicate `else'/2:
malformed_ite.m:051:   error: `->' without `;'.
malformed_ite.m:052: In clause for predicate `p'/2:
malformed_ite.m:052:   in argument 1 of call to predicate `else'/2:
malformed_ite.m:052:   in argument 2 of functor `->/2':
malformed_ite.m:052:   error: the language construct `='/2 should be used as a
malformed_ite.m:052:   goal, not as an expression.
malformed_ite.m:053: In clause for predicate `p'/2:
malformed_ite.m:053:   error: unmatched `else'.
malformed_ite.m:054: In clause for predicate `p'/2:
malformed_ite.m:054:   in argument 2 of call to predicate `else'/2:
malformed_ite.m:054:   error: the language construct `='/2 should be used as a
malformed_ite.m:054:   goal, not as an expression.
malformed_ite.m:059: In clause for predicate `p'/2:
malformed_ite.m:059:   error: `then' without `if' or `else'.
malformed_ite.m:060: In clause for predicate `p'/2:
malformed_ite.m:060:   in argument 2 of call to predicate `then'/2:
malformed_ite.m:060:   in argument 1 of functor `;/2':
malformed_ite.m:060:   error: the language construct `='/2 should be used as a
malformed_ite.m:060:   goal, not as an expression.
malformed_ite.m:061: In clause for predicate `p'/2:
malformed_ite.m:061:   in argument 2 of call to predicate `then'/2:
malformed_ite.m:061:   error: the language construct `;'/2 should be used as a
malformed_ite.m:061:   goal, not as an expression.
malformed_ite.m:062: In clause for predicate `p'/2:
malformed_ite.m:062:   in argument 2 of call to predicate `then'/2:
malformed_ite.m:062:   in argument 2 of functor `;/2':
malformed_ite.m:062:   error: the language construct `='/2 should be used as a
malformed_ite.m:062:   goal, not as an expression.
malformed_ite.m:067: In clause for predicate `p'/2:
malformed_ite.m:067:   error: undefined predicate `if'/1.
malformed_ite.m:068: In clause for predicate `p'/2:
malformed_ite.m:068:   in argument 1 of call to predicate `if'/1:
malformed_ite.m:068:   error: the language construct `='/2 should be used as a
malformed_ite.m:068:   goal, not as an expression.
malformed_ite.m:070: In clause for predicate `p'/2:
malformed_ite.m:070:   in argument 1 of call to predicate `if'/1:
malformed_ite.m:070:   error: the language construct `='/2 should be used as a
malformed_ite.m:070:   goal, not as an expression.
For more information, recompile with `-E'.

Zoltan.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.malformed_ite
Type: application/octet-stream
Size: 380 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20151127/5591484e/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.malformed_ite
Type: application/octet-stream
Size: 8954 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20151127/5591484e/attachment-0001.obj>


More information about the reviews mailing list