Concisely describe the proposed feature
We would like to support annotated assignment in the future, for example,
Since Taichi is statically typed, code snippet like this (which compiles in Python) would not compile in Taichi:
a: int = 1
a: float = 2.0
Describe the solution you'd like (if any)
Add a method build_AnnAssign in stmt_builder.py. The content of the method will be similar to build_Assign. It should also set the type when creating the variable, and check if the type is the same when an already-created variable is annotated assigned again.
The statement a: ti.i32 = 1 should be translated into the following CHI IR:
<i32> $0 = alloca
<i32> $1 = const [1]
<i32> $2 : local store [$0 <- $1]
Additional comments
The statement corresponds to ast.AnnAssign in the Python AST. See https://docs.python.org/3/library/ast.html#ast.AnnAssign for more information.
Concisely describe the proposed feature
We would like to support annotated assignment in the future, for example,
Since Taichi is statically typed, code snippet like this (which compiles in Python) would not compile in Taichi:
Describe the solution you'd like (if any)
Add a method
build_AnnAssigninstmt_builder.py. The content of the method will be similar tobuild_Assign. It should also set the type when creating the variable, and check if the type is the same when an already-created variable is annotated assigned again.The statement
a: ti.i32 = 1should be translated into the following CHI IR:Additional comments
The statement corresponds to
ast.AnnAssignin the Python AST. See https://docs.python.org/3/library/ast.html#ast.AnnAssign for more information.