Skip to content

Commit

Permalink
fix: Properly report error for unsupported constants (#724)
Browse files Browse the repository at this point in the history
Fixes #721
  • Loading branch information
mark-koch authored Dec 18, 2024
1 parent 5898060 commit d0c2da4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion guppylang/checker/errors/type_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class TypeInferenceError(Error):
@dataclass(frozen=True)
class IllegalConstant(Error):
title: ClassVar[str] = "Unsupported constant"
span_label: ClassVar[str] = "Type `{ty}` is not supported"
span_label: ClassVar[str] = "Type `{python_ty.__name__}` is not supported"
python_ty: type


Expand Down
8 changes: 8 additions & 0 deletions tests/error/misc_errors/unsupported_const.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Error: Unsupported constant (at $FILE:7:8)
|
5 | @compile_guppy
6 | def foo() -> None:
7 | x = "foo"
| ^^^^^ Type `str` is not supported

Guppy compilation failed due to 1 previous error
7 changes: 7 additions & 0 deletions tests/error/misc_errors/unsupported_const.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from guppylang.std.builtins import array
from tests.util import compile_guppy


@compile_guppy
def foo() -> None:
x = "foo"

0 comments on commit d0c2da4

Please sign in to comment.