pushIterKey pushes the iteration key or index variable for a comprehension onto the scope stack.
(varName string, rangeExpr ast.Expr)
| 259 | |
| 260 | // pushIterKey pushes the iteration key or index variable for a comprehension onto the scope stack. |
| 261 | func (c *coster) pushIterKey(varName string, rangeExpr ast.Expr) { |
| 262 | rangeSize := c.sizeOrUnknown(rangeExpr) |
| 263 | container := c.getType(rangeExpr).Kind() |
| 264 | var size *SizeEstimate |
| 265 | subpath := "@keys" |
| 266 | if container == types.ListKind { |
| 267 | s := FixedSizeEstimate(1) |
| 268 | size = &s |
| 269 | subpath = "@indices" |
| 270 | } else if rangeSize.Key != nil && (c.modelVersion >= 1 || c.isLegacyTracked(rangeExpr)) { |
| 271 | size = rangeSize.Key |
| 272 | } |
| 273 | var varPath []string |
| 274 | if path := c.getPath(rangeExpr); len(path) > 0 || c.modelVersion < 1 { |
| 275 | varPath = append(path, subpath) |
| 276 | } |
| 277 | c.localVars.push(varName, rangeExpr, varPath, size) |
| 278 | } |
| 279 | |
| 280 | // pushIterValue pushes the iteration value variable for a comprehension onto the scope stack. |
| 281 | func (c *coster) pushIterValue(varName string, rangeExpr ast.Expr) { |
no test coverage detected