Skip to content

Expect generates code with non-existent out-of-scope variable #208

@Programmerino

Description

@Programmerino

The following code:

expect x <~ categorical([0.5, 0.5]):
    x

generates

(summate x4
 from 0
 to size
      (array x3 of size(x1):
       x1[x3]
       * (x1 = [1/2, 1/2]
          x2 = summate x0 from 0 to size(x1): x1[x0]
          if 0/1 < x2: nat2prob(x3) else: 0/1)):
   (array x3 of size(x1):
    x1[x3]
    * (x1 = [1/2, 1/2]
       x2 = summate x0 from 0 to size(x1): x1[x0]
       if 0/1 < x2: nat2prob(x3) else: 0/1))
     [x4])
/ x2

which is incorrect because:

Name not in scope: x1

4|       (array x3 of size(x1):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions