[vala/0.40] parser: Don't include assigned value in source_reference of constants



commit 9c52894dbc18fd9d8f74bd9498f74b4fb6980bf3
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Mar 8 18:46:02 2019 +0100

    parser: Don't include assigned value in source_reference of constants
    
    This is how it is done for fields already.

 vala/valaparser.vala | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/vala/valaparser.vala b/vala/valaparser.vala
index 802e5f4f8..d1f81de8a 100644
--- a/vala/valaparser.vala
+++ b/vala/valaparser.vala
@@ -2581,19 +2581,13 @@ public class Vala.Parser : CodeVisitor {
 
                type = parse_inline_array_type (type);
 
-               Expression initializer = null;
-               if (accept (TokenType.ASSIGN)) {
-                       initializer = parse_expression ();
-               }
-               expect (TokenType.SEMICOLON);
-
                // constant arrays don't own their element
                var array_type = type as ArrayType;
                if (array_type != null) {
                        array_type.element_type.value_owned = false;
                }
 
-               var c = new Constant (id, type, initializer, get_src (begin), comment);
+               var c = new Constant (id, type, null, get_src (begin), comment);
                c.access = access;
                if (ModifierFlags.EXTERN in flags || scanner.source_file.file_type == SourceFileType.PACKAGE) 
{
                        c.external = true;
@@ -2607,6 +2601,11 @@ public class Vala.Parser : CodeVisitor {
                        Report.warning (c.source_reference, "the modifier `static' is not applicable to 
constants");
                }
 
+               if (accept (TokenType.ASSIGN)) {
+                       c.value = parse_expression ();
+               }
+               expect (TokenType.SEMICOLON);
+
                parent.add_constant (c);
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]