Skip to content

Commit

Permalink
fix: minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
vberlier committed Jul 14, 2022
1 parent 054b039 commit 35a537e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions bolt/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,7 @@ def current(self) -> CompiledModule:
@property
def current_path(self) -> str:
"""Return the path corresponding to the currently executing module."""
if not self.stack:
raise ValueError("No module currently executing.")
if path := self.stack[-1].resource_location:
if path := self.current.resource_location:
return path
raise ValueError(
"Currently executing module has no associated resource location."
Expand Down Expand Up @@ -177,7 +175,7 @@ def __getitem__(self, current: Union[TextFileBase[Any], str]) -> CompiledModule:
or module.ast is compilation_unit.ast
):
return module
logger.debug('Code generation due to ast update for module "%s".', name)
logger.warning('Code generation due to ast update for module "%s".', name)

elif not compilation_unit.ast:
previous = self.database.current
Expand All @@ -188,8 +186,10 @@ def __getitem__(self, current: Union[TextFileBase[Any], str]) -> CompiledModule:
filename=compilation_unit.filename,
resource_location=compilation_unit.resource_location,
)
except DiagnosticError:
raise UnusableCompilationUnit("Parsing failed.", compilation_unit)
except DiagnosticError as exc:
raise UnusableCompilationUnit(
"Parsing failed.", compilation_unit
) from exc
finally:
self.database.current = previous
return self[current]
Expand Down
2 changes: 1 addition & 1 deletion bolt/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ def create_macro(cls, command: AstCommand) -> AstMacro:
node = command
while isinstance(subcommand := node.arguments[-1], AstCommand):
if isinstance(literal := node.arguments[0], AstMacroLiteral):
if literal.value == "macro":
if literal.value in ["macro", "from"]:
exc = InvalidSyntax(f'Forbidden literal "{literal.value}".')
raise set_location(exc, literal)
identifier_parts.append(literal.value)
Expand Down

0 comments on commit 35a537e

Please sign in to comment.