Skip to content

Commit 33a7f97

Browse files
authored
Default enable using hidden accumulator name. (#1099)
* Default enable using hidden accumulator name. Switches the default accumulator name to '@Result' for standard macros. The resulting ASTs are semantically equivalent, but may break checks that assumed the old name. * Formatting fixes.
1 parent ee426f4 commit 33a7f97

File tree

7 files changed

+151
-187
lines changed

7 files changed

+151
-187
lines changed

checker/checker_test.go

+55-55
Original file line numberDiff line numberDiff line change
@@ -561,23 +561,23 @@ _==_(size(x~google.expr.proto3.test.TestAllTypes^x.map_int64_nested_type
561561
// Target
562562
x~bool^x,
563563
// Accumulator
564-
__result__,
564+
@result,
565565
// Init
566566
true~bool,
567567
// LoopCondition
568568
@not_strictly_false(
569-
__result__~bool^__result__
569+
@result~bool^@result
570570
)~bool^not_strictly_false,
571571
// LoopStep
572572
_&&_(
573-
__result__~bool^__result__,
573+
@result~bool^@result,
574574
_==_(
575575
y~!error!^y,
576576
true~bool
577577
)~bool^equals
578578
)~bool^logical_and,
579579
// Result
580-
__result__~bool^__result__)~bool
580+
@result~bool^@result)~bool
581581
`,
582582
err: `ERROR: <input>:1:1: expression of type 'bool' cannot be range of a comprehension (must be list, map, or dynamic)
583583
| x.all(y, y == true)
@@ -597,22 +597,22 @@ _==_(size(x~google.expr.proto3.test.TestAllTypes^x.map_int64_nested_type
597597
// Target
598598
x~google.expr.proto3.test.TestAllTypes^x.repeated_int64~list(int),
599599
// Accumulator
600-
__result__,
600+
@result,
601601
// Init
602602
[]~list(double),
603603
// LoopCondition
604604
true~bool,
605605
// LoopStep
606606
_+_(
607-
__result__~list(double)^__result__,
607+
@result~list(double)^@result,
608608
[
609609
double(
610610
x~int^x
611611
)~double^int64_to_double
612612
]~list(double)
613613
)~list(double)^add_list,
614614
// Result
615-
__result__~list(double)^__result__)~list(double)
615+
@result~list(double)^@result)~list(double)
616616
`,
617617
outType: types.NewListType(types.DoubleType),
618618
},
@@ -630,7 +630,7 @@ _==_(size(x~google.expr.proto3.test.TestAllTypes^x.map_int64_nested_type
630630
// Target
631631
x~google.expr.proto3.test.TestAllTypes^x.repeated_int64~list(int),
632632
// Accumulator
633-
__result__,
633+
@result,
634634
// Init
635635
[]~list(double),
636636
// LoopCondition
@@ -642,17 +642,17 @@ _==_(size(x~google.expr.proto3.test.TestAllTypes^x.map_int64_nested_type
642642
0~int
643643
)~bool^greater_int64,
644644
_+_(
645-
__result__~list(double)^__result__,
645+
@result~list(double)^@result,
646646
[
647647
double(
648648
x~int^x
649649
)~double^int64_to_double
650650
]~list(double)
651651
)~list(double)^add_list,
652-
__result__~list(double)^__result__
652+
@result~list(double)^@result
653653
)~list(double)^conditional,
654654
// Result
655-
__result__~list(double)^__result__)~list(double)
655+
@result~list(double)^@result)~list(double)
656656
`,
657657
outType: types.NewListType(types.DoubleType),
658658
},
@@ -887,56 +887,56 @@ ERROR: <input>:1:16: found no matching overload for '_!=_' applied to '(int, nul
887887
// Target
888888
x~google.expr.proto3.test.TestAllTypes^x.repeated_int64~list(int),
889889
// Accumulator
890-
__result__,
890+
@result,
891891
// Init
892892
true~bool,
893893
// LoopCondition
894894
@not_strictly_false(
895-
__result__~bool^__result__
895+
@result~bool^@result
896896
)~bool^not_strictly_false,
897897
// LoopStep
898898
_&&_(
899-
__result__~bool^__result__,
899+
@result~bool^@result,
900900
_>_(
901901
e~int^e,
902902
0~int
903903
)~bool^greater_int64
904904
)~bool^logical_and,
905905
// Result
906-
__result__~bool^__result__)~bool,
906+
@result~bool^@result)~bool,
907907
__comprehension__(
908908
// Variable
909909
e,
910910
// Target
911911
x~google.expr.proto3.test.TestAllTypes^x.repeated_int64~list(int),
912912
// Accumulator
913-
__result__,
913+
@result,
914914
// Init
915915
false~bool,
916916
// LoopCondition
917917
@not_strictly_false(
918918
!_(
919-
__result__~bool^__result__
919+
@result~bool^@result
920920
)~bool^logical_not
921921
)~bool^not_strictly_false,
922922
// LoopStep
923923
_||_(
924-
__result__~bool^__result__,
924+
@result~bool^@result,
925925
_<_(
926926
e~int^e,
927927
0~int
928928
)~bool^less_int64
929929
)~bool^logical_or,
930930
// Result
931-
__result__~bool^__result__)~bool
931+
@result~bool^@result)~bool
932932
)~bool^logical_and,
933933
__comprehension__(
934934
// Variable
935935
e,
936936
// Target
937937
x~google.expr.proto3.test.TestAllTypes^x.repeated_int64~list(int),
938938
// Accumulator
939-
__result__,
939+
@result,
940940
// Init
941941
0~int,
942942
// LoopCondition
@@ -948,14 +948,14 @@ ERROR: <input>:1:16: found no matching overload for '_!=_' applied to '(int, nul
948948
0~int
949949
)~bool^equals,
950950
_+_(
951-
__result__~int^__result__,
951+
@result~int^@result,
952952
1~int
953953
)~int^add_int64,
954-
__result__~int^__result__
954+
@result~int^@result
955955
)~int^conditional,
956956
// Result
957957
_==_(
958-
__result__~int^__result__,
958+
@result~int^@result,
959959
1~int
960960
)~bool^equals)~bool
961961
)~bool^logical_and`,
@@ -986,7 +986,7 @@ ERROR: <input>:1:10: expected type 'bool' but found 'int'
986986
// Target
987987
lists~dyn^lists,
988988
// Accumulator
989-
__result__,
989+
@result,
990990
// Init
991991
[]~list(dyn),
992992
// LoopCondition
@@ -998,15 +998,15 @@ ERROR: <input>:1:10: expected type 'bool' but found 'int'
998998
1.5~double
999999
)~bool^greater_double|greater_int64_double|greater_uint64_double,
10001000
_+_(
1001-
__result__~list(dyn)^__result__,
1001+
@result~list(dyn)^@result,
10021002
[
10031003
x~dyn^x
10041004
]~list(dyn)
10051005
)~list(dyn)^add_list,
1006-
__result__~list(dyn)^__result__
1006+
@result~list(dyn)^@result
10071007
)~list(dyn)^conditional,
10081008
// Result
1009-
__result__~list(dyn)^__result__)~list(dyn)`,
1009+
@result~list(dyn)^@result)~list(dyn)`,
10101010
outType: types.NewListType(types.DynType),
10111011
env: testEnv{
10121012
idents: []*decls.VariableDecl{
@@ -1381,7 +1381,7 @@ _&&_(_==_(list~type(list(dyn))^list,
13811381
"myextension"~string
13821382
)~dyn^index_map.customAttributes~dyn,
13831383
// Accumulator
1384-
__result__,
1384+
@result,
13851385
// Init
13861386
[]~list(dyn),
13871387
// LoopCondition
@@ -1393,15 +1393,15 @@ _&&_(_==_(list~type(list(dyn))^list,
13931393
"hobbies"~string
13941394
)~bool^equals,
13951395
_+_(
1396-
__result__~list(dyn)^__result__,
1396+
@result~list(dyn)^@result,
13971397
[
13981398
x~dyn^x
13991399
]~list(dyn)
14001400
)~list(dyn)^add_list,
1401-
__result__~list(dyn)^__result__
1401+
@result~list(dyn)^@result
14021402
)~list(dyn)^conditional,
14031403
// Result
1404-
__result__~list(dyn)^__result__)~list(dyn)`,
1404+
@result~list(dyn)^@result)~list(dyn)`,
14051405
env: testEnv{
14061406
idents: []*decls.VariableDecl{
14071407
decls.NewVariable("args", types.NewMapType(types.StringType, types.DynType)),
@@ -1867,14 +1867,14 @@ _&&_(_==_(list~type(list(dyn))^list,
18671867
1~int
18681868
]~list(int),
18691869
// Accumulator
1870-
__result__,
1870+
@result,
18711871
// Init
18721872
[]~list(list(int)),
18731873
// LoopCondition
18741874
true~bool,
18751875
// LoopStep
18761876
_+_(
1877-
__result__~list(list(int))^__result__,
1877+
@result~list(list(int))^@result,
18781878
[
18791879
[
18801880
x~int^x,
@@ -1883,16 +1883,16 @@ _&&_(_==_(list~type(list(dyn))^list,
18831883
]~list(list(int))
18841884
)~list(list(int))^add_list,
18851885
// Result
1886-
__result__~list(list(int))^__result__)~list(list(int)),
1886+
@result~list(list(int))^@result)~list(list(int)),
18871887
// Accumulator
1888-
__result__,
1888+
@result,
18891889
// Init
18901890
[]~list(list(list(int))),
18911891
// LoopCondition
18921892
true~bool,
18931893
// LoopStep
18941894
_+_(
1895-
__result__~list(list(list(int)))^__result__,
1895+
@result~list(list(list(int)))^@result,
18961896
[
18971897
[
18981898
x~list(int)^x,
@@ -1901,7 +1901,7 @@ _&&_(_==_(list~type(list(dyn))^list,
19011901
]~list(list(list(int)))
19021902
)~list(list(list(int)))^add_list,
19031903
// Result
1904-
__result__~list(list(list(int)))^__result__)~list(list(list(int)))
1904+
@result~list(list(list(int)))^@result)~list(list(list(int)))
19051905
`,
19061906
},
19071907
{
@@ -1922,7 +1922,7 @@ _&&_(_==_(list~type(list(dyn))^list,
19221922
// Target
19231923
values~list(map(string, string))^values,
19241924
// Accumulator
1925-
__result__,
1925+
@result,
19261926
// Init
19271927
[]~list(map(string, string)),
19281928
// LoopCondition
@@ -1934,30 +1934,30 @@ _&&_(_==_(list~type(list(dyn))^list,
19341934
""~string
19351935
)~bool^not_equals,
19361936
_+_(
1937-
__result__~list(map(string, string))^__result__,
1937+
@result~list(map(string, string))^@result,
19381938
[
19391939
i~map(string, string)^i
19401940
]~list(map(string, string))
19411941
)~list(map(string, string))^add_list,
1942-
__result__~list(map(string, string))^__result__
1942+
@result~list(map(string, string))^@result
19431943
)~list(map(string, string))^conditional,
19441944
// Result
1945-
__result__~list(map(string, string))^__result__)~list(map(string, string)),
1945+
@result~list(map(string, string))^@result)~list(map(string, string)),
19461946
// Accumulator
1947-
__result__,
1947+
@result,
19481948
// Init
19491949
[]~list(string),
19501950
// LoopCondition
19511951
true~bool,
19521952
// LoopStep
19531953
_+_(
1954-
__result__~list(string)^__result__,
1954+
@result~list(string)^@result,
19551955
[
19561956
i~map(string, string)^i.content~string
19571957
]~list(string)
19581958
)~list(string)^add_list,
19591959
// Result
1960-
__result__~list(string)^__result__)~list(string)`,
1960+
@result~list(string)^@result)~list(string)`,
19611961
},
19621962
{
19631963
in: `[{}.map(c,c,c)]+[{}.map(c,c,c)]`,
@@ -1970,7 +1970,7 @@ _&&_(_==_(list~type(list(dyn))^list,
19701970
// Target
19711971
{}~map(bool, dyn),
19721972
// Accumulator
1973-
__result__,
1973+
@result,
19741974
// Init
19751975
[]~list(bool),
19761976
// LoopCondition
@@ -1979,15 +1979,15 @@ _&&_(_==_(list~type(list(dyn))^list,
19791979
_?_:_(
19801980
c~bool^c,
19811981
_+_(
1982-
__result__~list(bool)^__result__,
1982+
@result~list(bool)^@result,
19831983
[
19841984
c~bool^c
19851985
]~list(bool)
19861986
)~list(bool)^add_list,
1987-
__result__~list(bool)^__result__
1987+
@result~list(bool)^@result
19881988
)~list(bool)^conditional,
19891989
// Result
1990-
__result__~list(bool)^__result__)~list(bool)
1990+
@result~list(bool)^@result)~list(bool)
19911991
]~list(list(bool)),
19921992
[
19931993
__comprehension__(
@@ -1996,7 +1996,7 @@ _&&_(_==_(list~type(list(dyn))^list,
19961996
// Target
19971997
{}~map(bool, dyn),
19981998
// Accumulator
1999-
__result__,
1999+
@result,
20002000
// Init
20012001
[]~list(bool),
20022002
// LoopCondition
@@ -2005,15 +2005,15 @@ _&&_(_==_(list~type(list(dyn))^list,
20052005
_?_:_(
20062006
c~bool^c,
20072007
_+_(
2008-
__result__~list(bool)^__result__,
2008+
@result~list(bool)^@result,
20092009
[
20102010
c~bool^c
20112011
]~list(bool)
20122012
)~list(bool)^add_list,
2013-
__result__~list(bool)^__result__
2013+
@result~list(bool)^@result
20142014
)~list(bool)^conditional,
20152015
// Result
2016-
__result__~list(bool)^__result__)~list(bool)
2016+
@result~list(bool)^@result)~list(bool)
20172017
]~list(list(bool))
20182018
)~list(list(bool))^add_list`,
20192019
},
@@ -2241,14 +2241,14 @@ _&&_(_==_(list~type(list(dyn))^list,
22412241
// Target
22422242
{}~map(dyn, dyn),
22432243
// Accumulator
2244-
__result__,
2244+
@result,
22452245
// Init
22462246
[]~list(list(dyn)),
22472247
// LoopCondition
22482248
true~bool,
22492249
// LoopStep
22502250
_+_(
2251-
__result__~list(list(dyn))^__result__,
2251+
@result~list(list(dyn))^@result,
22522252
[
22532253
[
22542254
c~dyn^c,
@@ -2259,7 +2259,7 @@ _&&_(_==_(list~type(list(dyn))^list,
22592259
]~list(list(dyn))
22602260
)~list(list(dyn))^add_list,
22612261
// Result
2262-
__result__~list(list(dyn))^__result__)~list(list(dyn))`,
2262+
@result~list(list(dyn))^@result)~list(list(dyn))`,
22632263
outType: types.NewListType(types.NewListType(types.DynType)),
22642264
},
22652265
}

0 commit comments

Comments
 (0)