Goose  Diff

Differences From Artifact [eca010aca9]:

  • File bs/builtins/types/overloadset/invoke.cpp — part of check-in [43e22af793] at 2019-08-05 02:45:01 on branch trunk —
    • Unification now works in two passes. The second pass gives unification rules a chance to match again after all the holes have been resolved and substituted.
    • Fixed many horrible bugs in various unification rules that managed to go by unnoticed until the above change, after which they made everything catch on fire.
    • Simplified the ct_int and ct_string unification rules to take advantage of the new unification behavior. Everything finally works as intended wrt to ct_int versus RT integers.
    • Removed unification callbacks. It was a system to provide a way to perform unification work post hole substitution, so it is now obsolete.
    (user: achavasse size: 2269)

To Artifact [dcda779ed3]:

  • File bs/builtins/types/overloadset/invoke.cpp — part of check-in [b8548d8b24] at 2019-08-11 17:18:45 on branch trunk —
    • Converted more error messages to the new system.
    • Propagated value locations in some missing places.
    • Added the location of template function calls as diagnostics context.
    (user: achavasse size: 2444)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "builtins/builtins.h"

using namespace empathy::sema;

namespace empathy::builtins
{
    class OverloadSetInvocationRule : public InvocationRule
    {
        public:
            optional< Value > resolveInvocation( const Context& c, const Value& callee, const Value& args ) const final
            {
                auto pOvlSet = *FromValue< ptr< OverloadSet > >( callee );

                UnificationContext uc( c );

                optional< UnificationContext > bestUC;
                optional< Term > bestSol;









|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "builtins/builtins.h"

using namespace empathy::sema;

namespace empathy::builtins
{
    class OverloadSetInvocationRule : public InvocationRule
    {
        public:
            optional< Value > resolveInvocation( const Context& c, uint32_t loc, const Value& callee, const Value& args ) const final
            {
                auto pOvlSet = *FromValue< ptr< OverloadSet > >( callee );

                UnificationContext uc( c );

                optional< UnificationContext > bestUC;
                optional< Term > bestSol;
35
36
37
38
39
40
41
42

43
44
45
46
47
48
49

50
51
52
53
54
55
56
57
58
59
60
61

                    if( bestOvl != &ovl )
                        ambiguous = true;
                }

                if( ambiguous )
                {
                    // TODO error mgmt

                    cout << "ambiguous function call.\n";
                    return nullopt;
                }

                if( !bestSol )
                {
                    // TODO error mgmt

                    cout << "function arguments mismatch.\n";
                    return nullopt;
                }

                return bestOvl->pInvRule->invoke( c, *bestOvl->callee, *bestSol, *bestUC );
            }
    };

    ptr< InvocationRule >& GetOverloadSetInvocationRule()
    {
        static ptr< InvocationRule > pRule = make_shared< OverloadSetInvocationRule >();
        return pRule;







|
>
|





|
>
|



|







35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63

                    if( bestOvl != &ovl )
                        ambiguous = true;
                }

                if( ambiguous )
                {
                    // TODO display details
                    DiagnosticsManager::GetInstance().emitErrorMessage( loc,
                        "ambiguous function call." );
                    return nullopt;
                }

                if( !bestSol )
                {
                    // TODO display details
                    DiagnosticsManager::GetInstance().emitErrorMessage( loc,
                        "function arguments mismatch." );
                    return nullopt;
                }

                return bestOvl->pInvRule->invoke( c, loc, *bestOvl->callee, *bestSol, *bestUC );
            }
    };

    ptr< InvocationRule >& GetOverloadSetInvocationRule()
    {
        static ptr< InvocationRule > pRule = make_shared< OverloadSetInvocationRule >();
        return pRule;