summaryrefslogtreecommitdiff
path: root/vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2022-02-28 12:12:56 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2022-02-28 12:12:56 +0100
commit2d4acc80e838f0ebd3520875bbbf2ba61bd2f234 (patch)
treef5d87b68771154911d1ddcab9cdc720075809225 /vala
parent03e74e5ecf286a43e5b6fa4ea986ae2031331245 (diff)
downloadvala-2d4acc80e838f0ebd3520875bbbf2ba61bd2f234.tar.gz
girparser: Handle duplicated and unnamed symbols
Issue warnings and skip such symbols to avoid errors on vala's side.
Diffstat (limited to 'vala')
-rw-r--r--vala/valagirparser.vala12
1 files changed, 12 insertions, 0 deletions
diff --git a/vala/valagirparser.vala b/vala/valagirparser.vala
index 6b3d69357..88f38434b 100644
--- a/vala/valagirparser.vala
+++ b/vala/valagirparser.vala
@@ -1535,6 +1535,18 @@ public class Vala.GirParser : CodeVisitor {
const string GIR_VERSION = "1.2";
static void add_symbol_to_container (Symbol container, Symbol sym) {
+ if (sym.name == "") {
+ Report.warning (sym.source_reference, "node with empty name");
+ return;
+ } else if (sym.name != null) {
+ Symbol? old_sym = container.scope.lookup (sym.name);
+ if (old_sym != null) {
+ Report.warning (sym.source_reference, "`%s' already contains a definition for `%s'", container.name, sym.name);
+ Report.notice (old_sym.source_reference, "previous definition of `%s' was here", old_sym.name);
+ return;
+ }
+ }
+
if (container is Class) {
unowned Class cl = (Class) container;