@@ -249,7 +249,7 @@ func quantifierAll(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (
249
249
target ,
250
250
iterVar1 ,
251
251
iterVar2 ,
252
- parser . AccumulatorName ,
252
+ mef . AccuIdentName () ,
253
253
/*accuInit=*/ mef .NewLiteral (types .True ),
254
254
/*condition=*/ mef .NewCall (operators .NotStrictlyFalse , mef .NewAccuIdent ()),
255
255
/*step=*/ mef .NewCall (operators .LogicalAnd , mef .NewAccuIdent (), args [2 ]),
@@ -267,7 +267,7 @@ func quantifierExists(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr
267
267
target ,
268
268
iterVar1 ,
269
269
iterVar2 ,
270
- parser . AccumulatorName ,
270
+ mef . AccuIdentName () ,
271
271
/*accuInit=*/ mef .NewLiteral (types .False ),
272
272
/*condition=*/ mef .NewCall (operators .NotStrictlyFalse , mef .NewCall (operators .LogicalNot , mef .NewAccuIdent ())),
273
273
/*step=*/ mef .NewCall (operators .LogicalOr , mef .NewAccuIdent (), args [2 ]),
@@ -285,7 +285,7 @@ func quantifierExistsOne(mef cel.MacroExprFactory, target ast.Expr, args []ast.E
285
285
target ,
286
286
iterVar1 ,
287
287
iterVar2 ,
288
- parser . AccumulatorName ,
288
+ mef . AccuIdentName () ,
289
289
/*accuInit=*/ mef .NewLiteral (types .Int (0 )),
290
290
/*condition=*/ mef .NewLiteral (types .True ),
291
291
/*step=*/ mef .NewCall (operators .Conditional , args [2 ],
@@ -311,18 +311,18 @@ func transformList(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (
311
311
transform = args [2 ]
312
312
}
313
313
314
- // __result__ = __result__ + [transform]
314
+ // accumulator = accumulator + [transform]
315
315
step := mef .NewCall (operators .Add , mef .NewAccuIdent (), mef .NewList (transform ))
316
316
if filter != nil {
317
- // __result__ = (filter) ? __result__ + [transform] : __result__
317
+ // accumulator = (filter) ? accumulator + [transform] : accumulator
318
318
step = mef .NewCall (operators .Conditional , filter , step , mef .NewAccuIdent ())
319
319
}
320
320
321
321
return mef .NewComprehensionTwoVar (
322
322
target ,
323
323
iterVar1 ,
324
324
iterVar2 ,
325
- parser . AccumulatorName ,
325
+ mef . AccuIdentName () ,
326
326
/*accuInit=*/ mef .NewList (),
327
327
/*condition=*/ mef .NewLiteral (types .True ),
328
328
step ,
@@ -346,17 +346,17 @@ func transformMap(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (a
346
346
transform = args [2 ]
347
347
}
348
348
349
- // __result__ = cel.@mapInsert(__result__ , iterVar1, transform)
349
+ // accumulator = cel.@mapInsert(accumulator , iterVar1, transform)
350
350
step := mef .NewCall (mapInsert , mef .NewAccuIdent (), mef .NewIdent (iterVar1 ), transform )
351
351
if filter != nil {
352
- // __result__ = (filter) ? cel.@mapInsert(__result__ , iterVar1, transform) : __result__
352
+ // accumulator = (filter) ? cel.@mapInsert(accumulator , iterVar1, transform) : accumulator
353
353
step = mef .NewCall (operators .Conditional , filter , step , mef .NewAccuIdent ())
354
354
}
355
355
return mef .NewComprehensionTwoVar (
356
356
target ,
357
357
iterVar1 ,
358
358
iterVar2 ,
359
- parser . AccumulatorName ,
359
+ mef . AccuIdentName () ,
360
360
/*accuInit=*/ mef .NewMap (),
361
361
/*condition=*/ mef .NewLiteral (types .True ),
362
362
step ,
@@ -380,17 +380,17 @@ func transformMapEntry(mef cel.MacroExprFactory, target ast.Expr, args []ast.Exp
380
380
transform = args [2 ]
381
381
}
382
382
383
- // __result__ = cel.@mapInsert(__result__ , transform)
383
+ // accumulator = cel.@mapInsert(accumulator , transform)
384
384
step := mef .NewCall (mapInsert , mef .NewAccuIdent (), transform )
385
385
if filter != nil {
386
- // __result__ = (filter) ? cel.@mapInsert(__result__ , transform) : __result__
386
+ // accumulator = (filter) ? cel.@mapInsert(accumulator , transform) : accumulator
387
387
step = mef .NewCall (operators .Conditional , filter , step , mef .NewAccuIdent ())
388
388
}
389
389
return mef .NewComprehensionTwoVar (
390
390
target ,
391
391
iterVar1 ,
392
392
iterVar2 ,
393
- parser . AccumulatorName ,
393
+ mef . AccuIdentName () ,
394
394
/*accuInit=*/ mef .NewMap (),
395
395
/*condition=*/ mef .NewLiteral (types .True ),
396
396
step ,
@@ -410,10 +410,10 @@ func extractIterVars(mef cel.MacroExprFactory, arg0, arg1 ast.Expr) (string, str
410
410
if iterVar1 == iterVar2 {
411
411
return "" , "" , mef .NewError (arg1 .ID (), fmt .Sprintf ("duplicate variable name: %s" , iterVar1 ))
412
412
}
413
- if iterVar1 == parser .AccumulatorName {
413
+ if iterVar1 == mef . AccuIdentName () || iterVar1 == parser .AccumulatorName {
414
414
return "" , "" , mef .NewError (arg0 .ID (), "iteration variable overwrites accumulator variable" )
415
415
}
416
- if iterVar2 == parser .AccumulatorName {
416
+ if iterVar2 == mef . AccuIdentName () || iterVar2 == parser .AccumulatorName {
417
417
return "" , "" , mef .NewError (arg1 .ID (), "iteration variable overwrites accumulator variable" )
418
418
}
419
419
return iterVar1 , iterVar2 , nil
0 commit comments