jayduhon / inferno-os

Automatically exported from code.google.com/p/inferno-os
2 stars 0 forks source link

false limbo errors for pick coverage #212

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
limbo does not correctly check whether a pick statement covers all tags of
the pick adt.  when all the tags have their own body, it works correctly. 
when tags share a body because of an "or", it does not anymore.

the attached program testpickcover.b shows the problem.  function "bad"
should be fine (all pick tags are covered), but limbo complains with "no
return at end of function bad".

the attached patch makes the problem go away.  the error originates from
reach() which checks for reachability of instructions.  it seems casecom()
generates an instruction (or does other magic) when it thinks a "*" case is
needed.  this then causes reach() to think a return is missing.  i have
only tested it on testpickcover.b, not the entire inferno tree.

(now that i think of it, nlabels() is probably not the right name for the
function...)

to get an idea of the left/right's in nlabels(), here is a pick with  a
case for Elem0 or Elem1, and one for *.

pick case int labels 0 0
  := nothing 0 0
    name t ref T 0 0
    name tt ref T 0 0
  seq nothing 0 0
    label nothing 0 0
      seq nothing 0 0
        const Elem0 (0) int 0 0
        seq nothing 0 0
          const Elem1 (1) int 0 0
      scope nothing 0 0
        return nothing 0 0
          const elem0 or elem1 string 0 0
    seq nothing 0 0
      label nothing 0 0
        seq nothing 0 0
          * T 0 0
        scope nothing 0 0
          return nothing 0 0
            const other string 0 0

Original issue reported on code.google.com by mechiel@ueber.net on 3 Dec 2009 at 10:03

Attachments:

GoogleCodeExporter commented 9 years ago
committed changeset 506:35a14b9f6e7b

Original comment by Charles....@gmail.com on 4 Apr 2011 at 6:08