From: Rico Tzschichholz Date: Fri, 8 Mar 2019 17:46:02 +0000 (+0100) Subject: parser: Don't include assigned value in source_reference of constants X-Git-Tag: 0.44.0~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=389755543d10c3ae5ffc8786fbf5f06ee5ce7f15;p=thirdparty%2Fvala.git parser: Don't include assigned value in source_reference of constants This is how it is done for fields already. --- diff --git a/vala/valaparser.vala b/vala/valaparser.vala index 236ab4947..1a1320bb1 100644 --- a/vala/valaparser.vala +++ b/vala/valaparser.vala @@ -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); }