diff --git a/python/taichi/lang/ast/ast_transformer.py b/python/taichi/lang/ast/ast_transformer.py index 79a2bb8cf7297..ef405ce94582a 100644 --- a/python/taichi/lang/ast/ast_transformer.py +++ b/python/taichi/lang/ast/ast_transformer.py @@ -1011,28 +1011,19 @@ def build_Compare(ctx, node): ops_static = { ast.In: lambda l, r: l in r, ast.NotIn: lambda l, r: l not in r, - ast.Is: lambda l, r: l is r, - ast.IsNot: lambda l, r: l is not r, } if ctx.is_in_static_scope(): ops = {**ops, **ops_static} operands = [node.left.ptr] + [comparator.ptr for comparator in node.comparators] val = True for i, node_op in enumerate(node.ops): + if isinstance(node_op, (ast.Is, ast.IsNot)): + name = "is" if isinstance(node_op, ast.Is) else "is not" + raise TaichiSyntaxError(f'Operator "{name}" in Taichi scope is not supported.') l = operands[i] r = operands[i + 1] op = ops.get(type(node_op)) - if isinstance(node_op, (ast.Is, ast.IsNot)): - name = "is" if isinstance(node_op, ast.Is) else "is not" - warnings.warn_explicit( - f'Operator "{name}" in Taichi scope is deprecated, ' - f"and it will be removed in Taichi v1.6.0. " - f"Please avoid using it.", - DeprecationWarning, - ctx.file, - node.lineno + ctx.lineno_offset, - module="taichi", - ) + if op is None: if type(node_op) in ops_static: raise TaichiSyntaxError(f'"{type(node_op).__name__}" is only supported inside `ti.static`.') diff --git a/tests/python/test_ast_refactor.py b/tests/python/test_ast_refactor.py index 669c419dd724a..deab2b0310c44 100644 --- a/tests/python/test_ast_refactor.py +++ b/tests/python/test_ast_refactor.py @@ -164,17 +164,6 @@ def foo(a: ti.template()): assert a[i] == b[i] -@test_utils.test() -def test_compare_fail(): - with pytest.raises(ti.TaichiCompilationError, match='"Is" is only supported inside `ti.static`.'): - - @ti.kernel - def foo(): - None is None - - foo() - - @test_utils.test() def test_single_compare(): @ti.kernel diff --git a/tests/python/test_compare.py b/tests/python/test_compare.py index 487e88c70f7ee..84a335bc4c054 100644 --- a/tests/python/test_compare.py +++ b/tests/python/test_compare.py @@ -171,33 +171,6 @@ def foo(a: ti.template()) -> ti.i32: foo(ti.i32) -@test_utils.test() -def test_static_is(): - @ti.kernel - def is_f32(tp: ti.template()) -> ti.i32: - return ti.static(tp is ti.f32) - - @ti.kernel - def is_not_f32(tp: ti.template()) -> ti.i32: - return ti.static(tp is not ti.f32) - - assert is_f32(ti.f32) == 1 - assert is_f32(ti.i32) == 0 - assert is_not_f32(ti.f32) == 0 - assert is_not_f32(ti.i32) == 1 - - -@test_utils.test() -def test_non_static_is(): - with pytest.raises(ti.TaichiCompilationError, match='"Is" is only supported inside `ti.static`.'): - - @ti.kernel - def is_f32(tp: ti.template()) -> ti.i32: - return tp is ti.f32 - - is_f32(ti.f32) - - @test_utils.test(default_ip=ti.i64, require=ti.extension.data64) def test_compare_ret_type(): # The purpose of this test is to make sure a comparison returns i32 diff --git a/tests/python/test_deprecation.py b/tests/python/test_deprecation.py index f1feeaa4f54aa..a46ea7ca2b798 100644 --- a/tests/python/test_deprecation.py +++ b/tests/python/test_deprecation.py @@ -69,11 +69,8 @@ def test_deprecate_rwtexture_ndim(): @test_utils.test() -def test_deprecate_is_is_not(): - with pytest.warns( - DeprecationWarning, - match='Operator "is" in Taichi scope is deprecated, ' "and it will be removed in Taichi v1.6.0.", - ): +def test_remove_is_is_not(): + with pytest.raises(ti.TaichiSyntaxError, match='Operator "is" in Taichi scope is not supported'): @ti.kernel def func():