File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -1123,6 +1123,17 @@ func TestIssue105(t *testing.T) {
1123
1123
require .Contains (t , err .Error (), "ambiguous identifier Field" )
1124
1124
}
1125
1125
1126
+ func TestIssue_nested_closures (t * testing.T ) {
1127
+ code := `all(1..3, { all(1..3, { # > 0 }) and # > 0 })`
1128
+
1129
+ program , err := expr .Compile (code )
1130
+ require .NoError (t , err )
1131
+
1132
+ output , err := expr .Run (program , nil )
1133
+ require .NoError (t , err )
1134
+ require .True (t , output .(bool ))
1135
+ }
1136
+
1126
1137
//
1127
1138
// Mock types
1128
1139
//
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ type parser struct {
77
77
current Token
78
78
pos int
79
79
err * file.Error
80
- closure bool
80
+ depth int // closure call depth
81
81
}
82
82
83
83
type Tree struct {
@@ -219,7 +219,7 @@ func (p *parser) parsePrimary() Node {
219
219
return p .parsePostfixExpression (expr )
220
220
}
221
221
222
- if p .closure {
222
+ if p .depth > 0 {
223
223
if token .Is (Operator , "#" ) || token .Is (Operator , "." ) {
224
224
if token .Is (Operator , "#" ) {
225
225
p .next ()
@@ -377,9 +377,9 @@ func (p *parser) parseClosure() Node {
377
377
token := p .current
378
378
p .expect (Bracket , "{" )
379
379
380
- p .closure = true
380
+ p .depth ++
381
381
node := p .parseExpression (0 )
382
- p .closure = false
382
+ p .depth --
383
383
384
384
p .expect (Bracket , "}" )
385
385
closure := & ClosureNode {
You can’t perform that action at this time.
0 commit comments