Add warning for confusing object IDs

This commit is contained in:
James Westman 2023-05-08 10:19:19 -05:00
parent 77dc9350e9
commit 43fbf8cf8e
2 changed files with 14 additions and 0 deletions

View file

@ -23,6 +23,7 @@ from blueprintcompiler.language.values import StringValue
from .common import *
from .contexts import ValueTypeCtx
from .gobject_object import RESERVED_IDS
class Menu(AstNode):
@ -47,6 +48,11 @@ class Menu(AstNode):
if self.tokens["tag"] == "menu" and self.tokens["id"] is None:
raise CompileError("Menu requires an ID")
@validate("id")
def object_id_not_reserved(self):
if self.id in RESERVED_IDS:
raise CompileWarning(f"{self.id} may be a confusing object ID")
class MenuAttribute(AstNode):
tag_name = "attribute"