]> 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>
Fri, 8 Mar 2019 17:46:02 +0000 (18:46 +0100)
This is how it is done for fields already.

vala/valaparser.vala

index 236ab49477af026274b197486544529987814429..1a1320bb1b8658824059d23d8b4b038749646459 100644 (file)
@@ -2587,19 +2587,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;
@@ -2613,6 +2607,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);
        }