Skip to content

Commit

Permalink
Merge pull request #52 from NethermindEth/ElijahVlasov/wrong-annotati…
Browse files Browse the repository at this point in the history
…on-error-message

Add an error message for unexpected annotations
  • Loading branch information
ElijahVlasov authored Jan 26, 2023
2 parents 45c20ad + fcc6a6e commit 1987228
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ skip_gitignore = true

[tool.poetry]
name = "horus-compile"
version = "0.0.6.9"
version = "0.0.6.10"
authors = ["Nethermind <[email protected]>"]
description = "Use formally verified annotations in your Cairo code"
classifiers = [
Expand Down
2 changes: 1 addition & 1 deletion src/horus/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.0.6.9"
__version__ = "0.0.6.10"
26 changes: 16 additions & 10 deletions src/horus/compiler/parser_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ def commented_code_element(self, meta, value):

if comment is not None:
possible_annotation: str = comment.strip()

for annotation in [
"@pre",
"@post",
"@assert",
"@invariant",
"@declare",
"@storage_update",
]:
if possible_annotation.startswith(annotation):
if possible_annotation.startswith("@"):
annotation_type = possible_annotation.split(" ")[0].strip()

if annotation_type in [
"@pre",
"@post",
"@assert",
"@invariant",
"@declare",
"@storage_update",
]:
check = horus.compiler.parser.parse(
filename=self.input_file.filename,
code=possible_annotation,
Expand All @@ -79,6 +80,11 @@ def commented_code_element(self, meta, value):
check, code_elm=code_elem.code_elm
)
return code_elem
else:
raise ParserError(
f"Unexpected annotation type: {annotation_type}",
location=self.meta2loc(meta),
)

return super().commented_code_element(meta, value)

Expand Down

0 comments on commit 1987228

Please sign in to comment.