Goose  Diff

Differences From Artifact [0371053b20]:

  • File bs/builtins/statements/hif.cpp — part of check-in [157221e014] at 2019-08-11 13:36:12 on branch trunk — Ported more error messages to the DiagnosticsManager. (user: achavasse size: 4706)

To Artifact [e0fff003d3]:

  • File bs/builtins/statements/hif.cpp — part of check-in [972c1d8b47] at 2019-08-12 20:15:11 on branch trunk —
    • Implemented a system to temporarily silence error outputs.
    • Syntax errors now silence further errors encountered while parsing the same block and nested children blocks.
    • All errors are also silenced while speculatively attempting to evaluate invocations at compilation time.
    (user: achavasse size: 4736)

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
            auto& dm = DiagnosticsManager::GetInstance();

            auto pPrecBB = p.currentBB();

            auto np = p.makeNestedParser();
            if( !np.parseExpression( precedence::IfStmt ) )
            {
                dm.emitErrorMessage( locationId, "expected an expression following the #if statement1.", 0 );
                return false;
            }

            auto condVal = np.popValue();
            if( !condVal )
            {
                dm.emitErrorMessage( locationId, "expected an expression following the #if statement2.", 0 );
                return false;
            }

            const auto& context = p.resolver()->context();
            auto converted = ConvertValueToType( context, *condVal, GetValueType< bool >() );
            if( holds_alternative< ValUnifyError >( converted ) )
            {







|






|







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
            auto& dm = DiagnosticsManager::GetInstance();

            auto pPrecBB = p.currentBB();

            auto np = p.makeNestedParser();
            if( !np.parseExpression( precedence::IfStmt ) )
            {
                dm.emitSyntaxErrorMessage( locationId, "expected an expression following the #if statement1.", 0 );
                return false;
            }

            auto condVal = np.popValue();
            if( !condVal )
            {
                dm.emitSyntaxErrorMessage( locationId, "expected an expression following the #if statement2.", 0 );
                return false;
            }

            const auto& context = p.resolver()->context();
            auto converted = ConvertValueToType( context, *condVal, GetValueType< bool >() );
            if( holds_alternative< ValUnifyError >( converted ) )
            {
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
                dm.emitErrorMessage( condVal->locationId(), "the #if condition doesn't evaluate to a bool constant." );
                return false;
            }

            auto next = p.resolver()->lookAheadUnresolved();
            if( !next )
            {
                dm.emitErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
                return false;
            }

            auto decomp = Decompose( next->first, Val< Delimiter >() );
            if( !decomp || *decomp != Delimiter::OpenBrace )
            {
                dm.emitErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
                return false;
            }

            // Deal with the then block.
            if( *cond )
            {
                if( !p.parseBraceBlock() )







|






|







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
                dm.emitErrorMessage( condVal->locationId(), "the #if condition doesn't evaluate to a bool constant." );
                return false;
            }

            auto next = p.resolver()->lookAheadUnresolved();
            if( !next )
            {
                dm.emitSyntaxErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
                return false;
            }

            auto decomp = Decompose( next->first, Val< Delimiter >() );
            if( !decomp || *decomp != Delimiter::OpenBrace )
            {
                dm.emitSyntaxErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
                return false;
            }

            // Deal with the then block.
            if( *cond )
            {
                if( !p.parseBraceBlock() )
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
                {
                    p.resolver()->consumeUnresolved();

                    auto next = p.resolver()->lookAheadUnresolved();
                    auto decomp = Decompose( next->first, Val< Delimiter >() );
                    if( !decomp || *decomp != Delimiter::OpenBrace )
                    {
                        dm.emitErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
                        return false;
                    }

                    // Deal with the else block.
                    if( !*cond )
                    {
                        if( !p.parseBraceBlock() )







|







100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
                {
                    p.resolver()->consumeUnresolved();

                    auto next = p.resolver()->lookAheadUnresolved();
                    auto decomp = Decompose( next->first, Val< Delimiter >() );
                    if( !decomp || *decomp != Delimiter::OpenBrace )
                    {
                        dm.emitSyntaxErrorMessage( p.resolver()->getCurrentLocation(), "brace block expected.", 0 );
                        return false;
                    }

                    // Deal with the else block.
                    if( !*cond )
                    {
                        if( !p.parseBraceBlock() )