gf-core icon indicating copy to clipboard operation
gf-core copied to clipboard

Indices for bound variables are wrong in the local environment

Open inariksit opened this issue 5 years ago • 0 comments

The problem

I was poking around Compute.ConcreteNew.hs trying to fix #52, and I noticed that the indices for bound variables (VGen Int [Value]) are not correct. You can even see this in #52: the offending piece of code is this

    x + "foo" => ss (x + "bar")

and the error is this.

unsupported token gluing: str + "bar"

My attempts

I added more printouts for the error message for unsupported token gluing, as follows:

in error . render $
   ppL loc (hang ("unsupported token gluing: "
                 ++ "(" ++ show v1 ++ ", " ++ show v2 ++ ")\n"
                 ++ show (local env) ++ "\n") 4
                  (Glue (vt v1) (vt v2)))

With this change, I can cause an error (unsupported token gluing in my case, both appropriate and inappropriate), and then I can see the variables I have in the local environment, and how vt prints out the wrong variable name for the index i in the VGen i xs.

I tried to remove the call to reverse in value2term but the indices were just differently wrong.

I don't dare touch this further, because this seems like a fundamental thing in the GF compiler. Originally I just wanted to add another case in the glue function to match the tokens that were erroneously covered by "unsupported token gluing".

inariksit avatar Jun 02 '20 19:06 inariksit