Skip to content

Commit

Permalink
skip appending path while variable argument evaluation (close #186)
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Aug 22, 2022
1 parent 6b47ae1 commit 77b3bcd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cli/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,14 @@
[0,1]
[[0,1],[0,1],[0,1],[0,1]]
- name: function declaration with update operator
args:
- -c
- 'def f: def f($x): .; f(.x) | .x; f += f'
input: '{"x": 1}'
expected: |
{"x":2}
- name: function declaration and recursive call
args:
- 'def f(g): if type == "array" then map(f(g * 2)) else g end; f(.)'
Expand Down Expand Up @@ -4754,6 +4762,15 @@
error: |
invalid path against: array ([])
- name: path function with function declaration
args:
- 'def f($x): .y; path(f(.x))'
input: 'null'
expected: |
[
"y"
]
- name: path function with error function
args:
- '[path(error)]'
Expand Down
2 changes: 2 additions & 0 deletions compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,12 @@ func (c *compiler) compileFuncDef(e *FuncDef, builtin bool) error {
}
for _, w := range vis {
c.append(&code{op: opload, v: v})
c.append(&code{op: opexpbegin})
c.append(&code{op: opload, v: w.index})
c.append(&code{op: opcallpc})
c.appendCodeInfo(w.name)
c.append(&code{op: opstore, v: c.pushVariable(w.name)})
c.append(&code{op: opexpend})
}
c.append(&code{op: opload, v: v})
}
Expand Down

0 comments on commit 77b3bcd

Please sign in to comment.