All packages, except for `cmd` and `internal`, have been moved into a new `v1` root package.
Old packages are kept for backwards-compatibility reasons. All contained code is replaced with simple type aliases and proxy functions to `v1` implementations.
Old packages default to the Rego v0 syntax, new `v1` packages default to the Rego v1 syntax.
Signed-off-by: Johan Fylling <johan.dev@fylling.se>
**main**
```
BenchmarkLintAllEnabled-10 1 2640715625 ns/op 6385110200 B/op 116296633 allocs/op
```
**pr**
```
BenchmarkLintAllEnabled-10 1 2597179708 ns/op 6183614112 B/op 108421141 allocs/op
```
(I renamed the benchmark, but this is the same as "regal linting itself"
used in the past)
Another 8 million allocations cut off from `regal lint bundle`,
and a whopping 10% improvements to wall clock time!
The most significant improvement is the Equal implementation for
refs, since that is called all over the place. But there are many
other fixes here, and they all contribute something substantial
(and fixes that only have had marginal impact have been left out).
Signed-off-by: Anders Eknert <anders@styra.com>
This adds a new option for eval which will disable indexing so
that variable bindings for rules that would otherwise not evaluate
can be found.
This also adds to (and corrects) the JSON marshalled trace events. We
now have extra metadata about the local variables, a working JSON
marshaller for the `Locals` (which includes type info), and the event
nodes location information.
Fixes: #1697
Signed-off-by: Patrick East <east.patrick@gmail.com>
The tracing instrumentation emits redos when evaluation *may* restart. This is
done so that expression redos are emitted before rule/body redos. E.g.,
given the expression p[x] > 1, the event stream should receive
redo(Expr(p[x] > 1)) before redo(Rule(p[x] = y :- ...)). Because redos are
emitted this way, the event stream contains many redos that only indicate that
the search has terminated because no more bindings could be found.
This change adds a stack/buffer to the context which is used to store redos.
When non-redo events are emitted, the buffer is flushed. When adding new redos
to the stack, we discard any that are no longer relevant, i.e., that indicate
that a search terminated because no more bindings could be fine.