Skip to content

Commit

Permalink
Add missing check method
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-koch committed Nov 27, 2023
1 parent 3e89ac8 commit b9c81ef
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions guppy/prelude/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,14 @@ def synthesize(self, args: list[ast.expr]) -> tuple[ast.expr, GuppyType]:
const = with_loc(self.node, ast.Constant(value=is_callable))
return const, BoolType()

def check(self, args: list[ast.expr], ty: GuppyType) -> ast.expr:
args, _ = self.synthesize(args)
if not isinstance(ty, BoolType):
raise GuppyTypeError(
f"Expected expression of type `{ty}`, got `bool`", self.node
)
return args


class IntTruedivCompiler(CustomCallCompiler):
"""Compiler for the `int.__truediv__` method."""
Expand Down

0 comments on commit b9c81ef

Please sign in to comment.