(call *ast.CallExpr, args []sem.Expr, argTypes []super.Type)
| 887 | } |
| 888 | |
| 889 | func (t *translator) semMapCall(call *ast.CallExpr, args []sem.Expr, argTypes []super.Type) (sem.Expr, super.Type) { |
| 890 | if len(args) != 2 { |
| 891 | t.error(call, errors.New("map requires two arguments")) |
| 892 | return badExpr, t.checker.unknown |
| 893 | } |
| 894 | ref, ok := args[1].(*sem.FuncRef) |
| 895 | if !ok { |
| 896 | t.error(call, errors.New("second argument to map must be a function")) |
| 897 | return badExpr, t.checker.unknown |
| 898 | } |
| 899 | elemType, ok := t.checker.hasArray(argTypes[0]) |
| 900 | if !ok { |
| 901 | t.error(call, errors.New("map expression must be an array")) |
| 902 | return badExpr, t.checker.unknown |
| 903 | } |
| 904 | mapArgs := []sem.Expr{sem.NewThis(call.Args[1], nil)} |
| 905 | mapTypes := []super.Type{elemType} |
| 906 | t.checker.pushErrs() |
| 907 | e, typ := t.resolver.resolveCall(call.Args[1], ref.ID, mapArgs, mapTypes) |
| 908 | errs := t.checker.popErrs() |
| 909 | for _, err := range errs { |
| 910 | t.error(err.loc, fmt.Errorf("in functon called from map: %w", err.err)) |
| 911 | } |
| 912 | if callExpr, ok := e.(*sem.CallExpr); ok { |
| 913 | return &sem.MapCallExpr{ |
| 914 | Node: call, |
| 915 | Expr: args[0], |
| 916 | Lambda: callExpr, |
| 917 | }, t.sctx.LookupTypeArray(typ) |
| 918 | } |
| 919 | return e, t.sctx.LookupTypeArray(typ) |
| 920 | } |
| 921 | |
| 922 | func (t *translator) semExtractExpr(e, partExpr, argExpr ast.Expr, inType super.Type) (sem.Expr, super.Type) { |
| 923 | var partstr string |
no test coverage detected