fugue / fregot

Fugue Rego Toolkit
Apache License 2.0
234 stars 11 forks source link

top-level variable assignments don't work #217

Closed srenatus closed 4 years ago

srenatus commented 4 years ago

x := "bar" outside a rule doesn't work with fregot:

$ cat foo.rego
package f

x := "bar"
$ fregot repl foo.rego
fregot (fatal parse error):
  "foo.rego" (line 3, column 3):
  parse failed:

    3| x := "bar"
         ^

  unexpected :=
  expecting var
$ opa run foo.rego
OPA 0.22.0-dev (commit ea20b6a2-dirty, built at 2020-06-25T12:02:21Z)

Run 'help' to see a list of commands and check for updates.

> data
{
  "f": {
    "x": "bar"
  }
}
>
jaspervdj-luminal commented 4 years ago

Oh! I kind of forgot about this feature. Fortunately it's fairly simple, I'm adding support for this in #218 and then it should be in the next release.

jaspervdj-luminal commented 4 years ago

@srenatus Thanks for reporting, this is now on master. Please give it a spin if you have time :-)