Skip to content

Commit

Permalink
[Error] Return TaichiTypeError in ASTTransformer when a binary op is …
Browse files Browse the repository at this point in the history
…not supported
  • Loading branch information
lin-hitonami authored and taichi-gardener committed Oct 31, 2022
1 parent b1b7fc8 commit e07baa8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions python/taichi/lang/ast/ast_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from taichi.lang.ast.ast_transformer_utils import (Builder, LoopStatus,
ReturnStatus)
from taichi.lang.ast.symbol_resolver import ASTResolver
from taichi.lang.exception import TaichiSyntaxError
from taichi.lang.exception import TaichiSyntaxError, TaichiTypeError
from taichi.lang.expr import Expr
from taichi.lang.field import Field
from taichi.lang.impl import current_cfg
Expand Down Expand Up @@ -803,7 +803,10 @@ def build_BinOp(ctx, node):
ast.BitAnd: lambda l, r: l & r,
ast.MatMult: lambda l, r: l @ r,
}.get(type(node.op))
node.ptr = op(node.left.ptr, node.right.ptr)
try:
node.ptr = op(node.left.ptr, node.right.ptr)
except TypeError as e:
raise TaichiTypeError(str(e))
return node.ptr

@staticmethod
Expand Down

0 comments on commit e07baa8

Please sign in to comment.