]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
parser: Reduce the source reference of main block method to its beginning
authorRico Tzschichholz <ricotz@ubuntu.com>
Tue, 18 Jan 2022 13:33:15 +0000 (14:33 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 16 Feb 2022 17:30:39 +0000 (18:30 +0100)
The end contains broken information which lead to a crash while trying to
report this multi-line source reference.

tests/Makefile.am
tests/parser/main-block-minimal.vala [new file with mode: 0644]
vala/valaparser.vala

index c3fad84518582c17dd0d7f6d22ef827c21aa4e60..f01ad7079909592865f5339f505140409f5f36a4 100644 (file)
@@ -865,6 +865,7 @@ TESTS = \
        parser/local-variable.vala \
        parser/lock-statement.vala \
        parser/main-block.vala \
+       parser/main-block-minimal.vala \
        parser/member-access-pointer.vala \
        parser/member-initializer.vala \
        parser/member-initializer-empty.vala \
diff --git a/tests/parser/main-block-minimal.vala b/tests/parser/main-block-minimal.vala
new file mode 100644 (file)
index 0000000..d029e43
--- /dev/null
@@ -0,0 +1 @@
+print ("foo");
index d2e42321a06087ced2faa90ccd39934d30bdd1b7..d40994dac099777dae43427ed89e68fe322aaf5b 100644 (file)
@@ -2367,7 +2367,7 @@ public class Vala.Parser : CodeVisitor {
        void parse_main_block (Symbol parent) throws ParseError {
                var begin = get_location ();
 
-               var method = new Method ("main", new VoidType (), get_src (begin));
+               var method = new Method ("main", new VoidType (), new SourceReference (scanner.source_file, begin, begin));
                method.access = SymbolAccessibility.PUBLIC;
                method.binding = MemberBinding.STATIC;
                method.body = new Block (get_src (begin));