diff --git a/blueprintcompiler/ast_utils.py b/blueprintcompiler/ast_utils.py index 4895744..19510eb 100644 --- a/blueprintcompiler/ast_utils.py +++ b/blueprintcompiler/ast_utils.py @@ -81,6 +81,8 @@ class AstNode: validator(self) except CompileError as e: yield e + if e.fatal: + return for child in self.children: yield from child._get_errors() diff --git a/blueprintcompiler/errors.py b/blueprintcompiler/errors.py index b8e6b6d..f880543 100644 --- a/blueprintcompiler/errors.py +++ b/blueprintcompiler/errors.py @@ -37,7 +37,7 @@ class CompileError(PrintableError): category = "error" color = Colors.RED - def __init__(self, message, start=None, end=None, did_you_mean=None, hints=None, actions=None): + def __init__(self, message, start=None, end=None, did_you_mean=None, hints=None, actions=None, fatal=False): super().__init__(message) self.message = message @@ -45,6 +45,7 @@ class CompileError(PrintableError): self.end = end self.hints = hints or [] self.actions = actions or [] + self.fatal = fatal if did_you_mean is not None: self._did_you_mean(*did_you_mean) diff --git a/blueprintcompiler/language/imports.py b/blueprintcompiler/language/imports.py index 2e519ed..cdef888 100644 --- a/blueprintcompiler/language/imports.py +++ b/blueprintcompiler/language/imports.py @@ -39,6 +39,11 @@ class GtkDirective(AstNode): err.hint("Expected 'using Gtk 4.0;'") raise err + try: + gir.get_namespace("Gtk", self.tokens["version"]) + except: + raise CompileError("Could not find GTK 4 introspection files. Is gobject-introspection installed?", fatal=True) + @property def gir_namespace(self):