Skip to content

Commit 5fde3c5

Browse files
committed
fix last/1 to be included in builtin/0
1 parent 689b491 commit 5fde3c5

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

_tools/gen_builtin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ func run(input, output string) error {
4848
}
4949
fds["_assign"] = nil
5050
fds["_modify"] = nil
51+
fds["_last"] = nil
5152
t, err := astgen.Build(fds)
5253
if err != nil {
5354
return err

builtin.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builtin.jq

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def walk(f):
5959
def first: .[0];
6060
def first(g): label $out | g | ., break $out;
6161
def last: .[-1];
62+
def last(g): _last(g);
6263
def isempty(g): label $out | (g | false, break $out), true;
6364
def all: all(.);
6465
def all(y): all(.[]; y);

compiler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ func (c *compiler) compileFunc(e *Func) error {
953953
c.compileAssign()
954954
case "_modify":
955955
c.compileModify()
956-
case "last":
956+
case "_last":
957957
c.compileLast()
958958
}
959959
}
@@ -1145,7 +1145,7 @@ func (c *compiler) compileModify() {
11451145
// Appends the compiled code for the `last/1` function to
11461146
// maximize performance avoiding unnecessary boxing.
11471147
func (c *compiler) compileLast() {
1148-
defer c.appendBuiltin("last", 1)()
1148+
defer c.appendBuiltin("_last", 1)()
11491149
scope := c.newScope()
11501150
v, g, x := [2]int{scope.id, 0}, [2]int{scope.id, 1}, [2]int{scope.id, 2}
11511151
c.appends(

0 commit comments

Comments
 (0)