[mercury-users] switch detection

Nicholas Nethercote njn at csse.unimelb.edu.au
Tue Jan 9 10:24:47 AEDT 2007


Hi,

Here's an interesting switch-detection failure.

In the following code, the switch on 'Lang' is detected fine.  You can see 
it has four alternatives, 'zinc', 'minizinc', 'flatzinc', and 'cadmium':

         Lang = !.S^lang,
         (   Lang = zinc,
             ...
         ;
           ( Lang = minizinc ;
             Lang = flatzinc ),
             ...
         ;
             Lang = cadmium,
             ...
         ),

But when I inline the record accesses like this (which is how I originally 
wrote the code):

         (   !.S^lang = zinc,
             ...
         ;
           ( !.S^lang = minizinc ;
             !.S^lang = flatzinc ),
             ...
         ;
             !.S^lang = cadmium,
             ...
         ),

the switch is not detected:

  type_inst_check.m:552:   error: determinism declaration not satisfied.
  type_inst_check.m:552:   Declared `det', inferred `nondet'.
  type_inst_check.m:615:   Disjunction has multiple clauses with solutions.
  type_inst_check.m:615:   Inside the case zinc_ast.set_of/1 of the switch on
  type_inst_check.m:615:   BaseTIETail : The switch on V_204 does not cover
  type_inst_check.m:615:   zinc_common.flatzinc/0 or zinc_common.minizinc/0.
  type_inst_check.m:617:   Inside the case zinc_ast.set_of/1 of the switch on
  type_inst_check.m:617:   BaseTIETail : The switch on V_198 does not cover
  type_inst_check.m:617:   zinc_common.cadmium/0 or zinc_common.zinc/0.

It's not a hard workaround, but it was a little surprising (Mercury's 
switch-detection is normally pretty good) and I thought it worth mentioning.

Nick
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list