[m-rev.] for post-commit review: fix some uint incomplete switches

Zoltan Somogyi zoltan.somogyi at runbox.com
Tue Mar 7 16:34:54 AEDT 2017


For post-commit review by Julien.

The INCOMPLETE attached file is the concatenation of all the stage2
.err files when bootcheck is invoked with the flags

EXTRA_MCFLAGS = --inform-incomplete-switch --inform-incomplete-switch-threshold=60

There is still a switch that is missing a case for uint in fact_table.m,
but I will fix that separately to avoid a git conflict.

I notice that most of the remaining messages are about code like this:

   ( X  = (<)
   ; X = (=)
   )

For comparison_result, it is obvious that there will never be a fourth
functor in the type, but other incomplete switches involve other types
for which that guarantee can't be given. I think that one possible solution
is to have humans rewrite such code as

  require_complete_switch [X]
  ( X = (<), Result = yes
  ; X = (=), Result = yes
  ; X = (>), Result = no
  ),
  Result = yes

and then have the simplify pass transform this back to the first version above.
Since the simplify pass is invoked *after* determinism analysis, which is the
pass that diagnoses switches that should be complete but aren't, this would get
the compiler to tell the programmer that the switch should be revisited when
the type of X has a new functor added to it (such as uint), while avoiding the
runtime impact of the assignment to, and test of, the extra variable.

What do people think?

Zoltan.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: Log.is
Type: application/octet-stream
Size: 333 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20170307/009f5833/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: DIFF.is
Type: application/octet-stream
Size: 9702 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20170307/009f5833/attachment-0004.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: INCOMPLETE9.60
Type: application/octet-stream
Size: 16572 bytes
Desc: not available
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20170307/009f5833/attachment-0005.obj>


More information about the reviews mailing list