(e ast.Expr)
| 423 | } |
| 424 | |
| 425 | func (c *checker) checkCreateList(e ast.Expr) { |
| 426 | create := e.AsList() |
| 427 | var elemsType *types.Type |
| 428 | optionalIndices := create.OptionalIndices() |
| 429 | optionals := make(map[int32]bool, len(optionalIndices)) |
| 430 | for _, optInd := range optionalIndices { |
| 431 | optionals[optInd] = true |
| 432 | } |
| 433 | for i, e := range create.Elements() { |
| 434 | c.check(e) |
| 435 | elemType := c.getType(e) |
| 436 | if optionals[int32(i)] { |
| 437 | var isOptional bool |
| 438 | elemType, isOptional = maybeUnwrapOptional(elemType) |
| 439 | if !isOptional && !isDyn(elemType) { |
| 440 | c.errors.typeMismatch(e.ID(), c.location(e), types.NewOptionalType(elemType), elemType) |
| 441 | } |
| 442 | } |
| 443 | elemsType = c.joinTypes(e, elemsType, elemType) |
| 444 | } |
| 445 | if elemsType == nil { |
| 446 | // If the list is empty, assign free type var to elem type. |
| 447 | elemsType = c.newTypeVar() |
| 448 | } |
| 449 | c.setType(e, types.NewListType(elemsType)) |
| 450 | } |
| 451 | |
| 452 | func (c *checker) checkCreateMap(e ast.Expr) { |
| 453 | mapVal := e.AsMap() |
no test coverage detected