Goose  Diff

Differences From Artifact [6f469edfd4]:

  • File bs/builtins/statements/using.cpp — part of check-in [1ad61a2717] at 2021-11-11 20:05:58 on branch trunk — Refactored the code builder: it is now carried around as a Value, and accessed through a bunch of extension points, so we can have different builders (and even user defined ones) later to make classes etc. (user: zlodo size: 3583)

To Artifact [2fa94e2fa4]:

  • File bs/builtins/statements/using.cpp — part of check-in [35ff2a536e] at 2021-11-26 22:42:06 on branch trunk —
    • Fixed adding predicates to a type alias created with using that modified the original type
    • Fixed ambiguous parsing of using expressions that were mistook for overload redefinitions in some cases
    (user: zlodo size: 4031)

24
25
26
27
28
29
30


31






32
33
34
35
36
37
38
39
40
41
42

43


44
45
46
47
48
49
50
            const auto* name = get_if< StringId >( &nameTerm->first );
            if( !name )
            {
                dm.emitSyntaxErrorMessage( nameTerm->second, "expected an identifier.", 0 );
                return false;
            }



            auto& context = p.context();







            // Create an identity to contain the visibility of any symbol defined inside of the using statement.
            // Since the current identity is that of the local variables of the current function and those
            // shouldn't be visible inside of the using statement, we simply replace the last element of the identity
            // by the name of the using definition, so that its parent becomes the current function's identity.
            //
            // TODO: we'll probably need a more sophisticated scheme to be able to deal with lambda captures
            // where localvars from the parent(s) functions should be visible, but still not visible inside of
            // using statements. But one mess of a feature at a time.
            auto localIdentity = TakeVectorTerm( context.identity(), VecSize( context.identity() ) - 1 );
            get< pvec >( localIdentity )->terms().back() = nameTerm->first;

            context.env()->addVisibilityRule( context.identity(), localIdentity );



            auto eqTerm = p.resolver()->consumeUnresolved();
            if( !eqTerm )
            {
                dm.emitSyntaxErrorMessage( p.resolver()->currentLocation(), "expected '='.", 0 );
                context.env()->storeValue( localIdentity, ANYTERM( _ ), ValueToEIR( PoisonValue() ) );
                return true;







>
>

>
>
>
>
>
>











>

>
>







24
25
26
27
28
29
30
31
32
33
34
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
            const auto* name = get_if< StringId >( &nameTerm->first );
            if( !name )
            {
                dm.emitSyntaxErrorMessage( nameTerm->second, "expected an identifier.", 0 );
                return false;
            }

            Parser::CurrentContextGuard ccg( p );

            auto& context = p.context();

            // we don't have a builder to parse using expresions. It disables
            // a number of things, in particular, the ability to overload functions.
            // This avoids unfortunate parsing ambiguiousness in some cases
            // (cf test g0/statements/e-using-2.g0)
            context.setBuilder( ToValue< void >() );

            // Create an identity to contain the visibility of any symbol defined inside of the using statement.
            // Since the current identity is that of the local variables of the current function and those
            // shouldn't be visible inside of the using statement, we simply replace the last element of the identity
            // by the name of the using definition, so that its parent becomes the current function's identity.
            //
            // TODO: we'll probably need a more sophisticated scheme to be able to deal with lambda captures
            // where localvars from the parent(s) functions should be visible, but still not visible inside of
            // using statements. But one mess of a feature at a time.
            auto localIdentity = TakeVectorTerm( context.identity(), VecSize( context.identity() ) - 1 );
            get< pvec >( localIdentity )->terms().back() = nameTerm->first;

            context.env()->addVisibilityRule( context.identity(), localIdentity );

            context.setIdentity( localIdentity );

            auto eqTerm = p.resolver()->consumeUnresolved();
            if( !eqTerm )
            {
                dm.emitSyntaxErrorMessage( p.resolver()->currentLocation(), "expected '='.", 0 );
                context.env()->storeValue( localIdentity, ANYTERM( _ ), ValueToEIR( PoisonValue() ) );
                return true;