Goose  Diff

Differences From Artifact [de316370aa]:

  • File bs/builtins/types/localvar/unify.cpp — part of check-in [ebdba2e941] at 2020-05-13 18:15:01 on branch trunk — References:
    • When doing variable declaration local type inference, look for an initialization function that takes a mutable reference on the lhs, instead of a local variable.
    • As a result of the above, got rid of Initialize() overloads for local variables.
    • The assignment operator now takes a mutable reference on the lhs, instead of directly working on a local variable.
    (user: achavasse size: 2410)

To Artifact [04833fdeb6]:

  • File bs/builtins/types/localvar/unify.cpp — part of check-in [c39a302502] at 2020-05-23 12:58:20 on branch trunk —
    • Fixed the hole matching score which prevented some unification rules to be selected.
    • Implemented LowerTypeForRuntime for tuples.
    • Implemented an unification rule for constant tuples.
    • Added some debugging helpers.
    (user: achavasse size: 2428)

11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
        auto localVarPattern = GetValueType< LocalVar >( ANYTERM( _ ) );

        auto refTypePattern = ValueToIRExpr(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), ANYTERM( _ ), ANYTERM( _ ) ) ) );

        // LocalVar unification against a param:
        // Build a mutable ref value.
        e.unificationRuleSet()->addSymRule(

            ParamPat( ANYTERM( _ ) ),

            ValueToIRExpr( ValuePattern(
                ANYTERM( _ ),
                localVarPattern,
                ANYTERM( _ ) ) ),







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
        auto localVarPattern = GetValueType< LocalVar >( ANYTERM( _ ) );

        auto refTypePattern = ValueToIRExpr(
            Value( GetValueType< ReferenceType >(), TVEC( TSID( reference ), ANYTERM( _ ), ANYTERM( _ ) ) ) );

        // LocalVar unification against a param:
        // Build a mutable ref value.
        e.unificationRuleSet()->addSymRule( URINFOS,

            ParamPat( ANYTERM( _ ) ),

            ValueToIRExpr( ValuePattern(
                ANYTERM( _ ),
                localVarPattern,
                ANYTERM( _ ) ) ),
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
                    .setLocationId( lvval.locationId() ) );

                // Unify the param with the ref
                co_yield Unify( lhs, ref, c );
            } );

        // LocalVar unification against another LocalVar: unify their types.
        e.unificationRuleSet()->addSymRule(

            ParamPat( localVarPattern ),

            ValueToIRExpr( ValuePattern(
                ANYTERM( _ ),
                localVarPattern,
                ANYTERM( _ ) ) ),







|







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
                    .setLocationId( lvval.locationId() ) );

                // Unify the param with the ref
                co_yield Unify( lhs, ref, c );
            } );

        // LocalVar unification against another LocalVar: unify their types.
        e.unificationRuleSet()->addSymRule( URINFOS,

            ParamPat( localVarPattern ),

            ValueToIRExpr( ValuePattern(
                ANYTERM( _ ),
                localVarPattern,
                ANYTERM( _ ) ) ),