Goose  Diff

Differences From Artifact [e031e517e9]:

  • File bs/builtins/types/func/invoke.cpp — part of check-in [0345b9f807] at 2021-01-02 18:00:11 on branch trunk — Some more renaming. (user: achavasse size: 3965)

To Artifact [b7fd6c3c37]:

  • File bs/builtins/types/func/invoke.cpp — part of check-in [7b9f645074] at 2021-01-21 21:05:48 on branch trunk — Removed the vector "typechecking rule", whose existence made no sense. Typechecking rules should operate only on values and pattern of values. Typechecking multiple values against multiple params is now done through a specific function instead. (user: achavasse size: 3961)

10
11
12
13
14
15
16
17

18
19

20
21
22
23
24
25
26
10
11
12
13
14
15
16

17
18

19
20
21
22
23
24
25
26







-
+

-
+







            Value resolveInvocation( const Context& c, uint32_t loc, const Value& callee, const Term& args ) const final
            {
                optional< TypeCheckingContext > bestTCC;
                optional< Term > bestSol;
                bool ambiguous = false;

                auto sig = GetFuncSig( callee );
                auto callPat = VEC( args, HOLE( "_"_sid ) );
                auto callPat = PrependToVectorTerm( args, HOLE( "_"_sid ) );

                auto us = FindBestTyping( sig, callPat, c );
                auto us = FindBestTypingVec( sig, callPat, c );

                if( holds_alternative< NoUnification >( us ) )
                {
                    // TODO display details
                    DiagnosticsManager::GetInstance().emitErrorMessage( loc,
                        "function arguments mismatch." );
                    return PoisonValue();
42
43
44
45
46
47
48
49

50
51
52
53
54

55

56
57
58
59
60
61
62
42
43
44
45
46
47
48

49



50
51
52

53
54
55
56
57
58
59
60







-
+
-
-
-


+
-
+







            Value invoke( const Context& c, uint32_t loc, const Value& callee, const Term& args, const Term& unifiedCallPat, TypeCheckingContext& tcc ) const final
            {
                auto newCallee = prepareFunc( c, 0, callee, unifiedCallPat, tcc );
                if( newCallee.isPoison() )
                    return PoisonValue();

                auto callDecomp = Decompose( unifiedCallPat,
                    Vec(
                    Val< pvec >()
                        SubTerm(),  // args
                        SubTerm()   // return type
                    )
                );

                const auto& unifiedRType = callDecomp->get()->terms().front();
                auto&& [unifiedArgs, unifiedRType] = *callDecomp;
                auto unifiedArgs = DropVectorTerm( unifiedCallPat, 1 );

                newCallee.setLocationId( loc );

                if( IsBuiltinFunc( newCallee ) )
                    return BuildComputedValue( unifiedRType, cir::Call( newCallee, unifiedArgs ) );

                if( IsIntrinsicFunc( newCallee ) )