]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
parser: Don't include assigned value in source_reference of constants
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 8 Mar 2019 17:46:02 +0000 (18:46 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 10 Apr 2019 14:09:29 +0000 (16:09 +0200)
This is how it is done for fields already.

vala/valaparser.vala

index 239de6bc170199640bfda6bdbf1ad66c30c502dc..42c300828226b5086346c59231578d2b258d8450 100644 (file)
@@ -2604,19 +2604,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;
@@ -2630,6 +2624,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);
        }