@@ -52,7 +52,7 @@ func TestCompile(t *testing.T) {
5252 "nested parse error" ,
5353 withTenantPrefix ,
5454 `definition foo {
55- relation something: rela | relb + relc
55+ relation something: rela | relb + relc
5656 }` ,
5757 "parse error in `nested parse error`, line 2, column 37: Expected end of statement or definition, found: TokenTypePlus" ,
5858 []SchemaDefinition {},
@@ -695,7 +695,7 @@ func TestCompile(t *testing.T) {
695695 "thirdParam" : caveattypes .Default .MustListType (caveattypes .Default .IntType ),
696696 },
697697 ), "sometenant/foo" ,
698- `someParam == 42 && someParam != 43 && someParam < 12 && someParam > 56
698+ `someParam == 42 && someParam != 43 && someParam < 12 && someParam > 56
699699 && anotherParam == "hi there" && 42 in thirdParam` ),
700700 },
701701 },
@@ -995,7 +995,7 @@ func TestCompile(t *testing.T) {
995995 "relation with expiration trait" ,
996996 withTenantPrefix ,
997997 `use expiration
998-
998+
999999 definition simple {
10001000 relation viewer: user with expiration
10011001 }` ,
@@ -1044,7 +1044,7 @@ func TestCompile(t *testing.T) {
10441044 "relation with expiration trait and caveat" ,
10451045 withTenantPrefix ,
10461046 `use expiration
1047-
1047+
10481048 definition simple {
10491049 relation viewer: user with somecaveat and expiration
10501050 }` ,
@@ -1117,24 +1117,23 @@ func TestCompile(t *testing.T) {
11171117
11181118func filterSourcePositions (m protoreflect.Message ) {
11191119 m .Range (func (fd protoreflect.FieldDescriptor , v protoreflect.Value ) bool {
1120- if fd .Kind () == protoreflect .MessageKind {
1121- if fd .IsList () {
1122- l := v .List ()
1123- for i := 0 ; i < l .Len (); i ++ {
1124- filterSourcePositions (l .Get (i ).Message ())
1125- }
1126- } else if fd .IsMap () {
1127- m := v .Map ()
1128- m .Range (func (k protoreflect.MapKey , v protoreflect.Value ) bool {
1129- filterSourcePositions (v .Message ())
1130- return true
1131- })
1120+ switch {
1121+ case fd .Kind () == protoreflect .MessageKind && fd .IsList ():
1122+ l := v .List ()
1123+ for i := 0 ; i < l .Len (); i ++ {
1124+ filterSourcePositions (l .Get (i ).Message ())
1125+ }
1126+ case fd .Kind () == protoreflect .MessageKind && fd .IsMap ():
1127+ m := v .Map ()
1128+ m .Range (func (k protoreflect.MapKey , v protoreflect.Value ) bool {
1129+ filterSourcePositions (v .Message ())
1130+ return true
1131+ })
1132+ case fd .Kind () == protoreflect .MessageKind :
1133+ if string (fd .Message ().Name ()) == "SourcePosition" {
1134+ m .Clear (fd )
11321135 } else {
1133- if string (fd .Message ().Name ()) == "SourcePosition" {
1134- m .Clear (fd )
1135- } else {
1136- filterSourcePositions (v .Message ())
1137- }
1136+ filterSourcePositions (v .Message ())
11381137 }
11391138 }
11401139 return true
0 commit comments