]> 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, 9 Feb 2022 21:17:35 +0000 (22:17 +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 f68930da6efe6e923396415bc5e60603081e4b47..69f687dc1ff939978e97fcbfd840af45910579a4 100644 (file)
@@ -889,6 +889,7 @@ TESTS = \
        parser/local-variable-array-type-invalid.test \
        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 c05f4ea669aa2505694694faa24a51734b666a7c..8661565f34ff4916713f55baef86d7982c06f77c 100644 (file)
@@ -2488,7 +2488,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));