(srcExpr ast.Expr)
| 135 | } |
| 136 | |
| 137 | func (c *transferChecker) VisitExpr(srcExpr ast.Expr) { |
| 138 | if srcRange, haveSrc := c.srcInfo.GetOffsetRange(srcExpr.ID()); haveSrc { |
| 139 | if srcRange.Start == 0 { |
| 140 | // Ignore synthetic "true" default condition which has an incorrect source location |
| 141 | return |
| 142 | } |
| 143 | dstExpr, haveDst := (*c.ranges)[srcRange] |
| 144 | if !haveDst { |
| 145 | c.t.Errorf("composed node not found for rule node: %s", debug.ToDebugString(srcExpr)) |
| 146 | return |
| 147 | } |
| 148 | |
| 149 | // Check that the two nodes have the same textual representation |
| 150 | if dstExpr.Kind() == ast.IdentKind && strings.HasPrefix(dstExpr.AsIdent(), "@index") { |
| 151 | // Skip the check for unnested vars |
| 152 | return |
| 153 | } |
| 154 | dstStr, err := cel.ExprToString(dstExpr, c.dstInfo) |
| 155 | if err != nil { |
| 156 | c.t.Errorf("failed to convert dstExpr") |
| 157 | return |
| 158 | } |
| 159 | srcStr, err := cel.ExprToString(srcExpr, c.srcInfo) |
| 160 | if err != nil { |
| 161 | c.t.Errorf("failed to convert srcExpr") |
| 162 | return |
| 163 | } |
| 164 | if srcStr != dstStr { |
| 165 | c.t.Errorf("mismatched nodes, rule: %s composed: %s", srcStr, dstStr) |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | func (c *transferChecker) VisitEntryExpr(ast.EntryExpr) { |
| 171 | } |
nothing calls this directly
no test coverage detected