Skip to content

Commit

Permalink
[Lang] [bug] Let static assert be in static scope (#8217)
Browse files Browse the repository at this point in the history
Issue: fix #8218 

### Brief Summary

<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at ec8cb2c</samp>

Add `static_assert` feature for compile-time assertions in Taichi.
Modify `ast_transformer.py` to handle the `static_assert` decorator.

### Walkthrough

<!--
copilot:walkthrough
-->
### <samp>🤖 Generated by Copilot at ec8cb2c</samp>

* Add support for `static_assert` decorator to enable compile-time
assertions
([link](https://github.com/taichi-dev/taichi/pull/8217/files?diff=unified&w=0#diff-3e22417ffade4af0564893b98dc5101d714b8ba6fd4423ab5bc5129e360fee8fL538-R538),
[link](https://github.com/taichi-dev/taichi/pull/8217/files?diff=unified&w=0#diff-3e22417ffade4af0564893b98dc5101d714b8ba6fd4423ab5bc5129e360fee8fR1119))
  • Loading branch information
lin-hitonami authored Jun 25, 2023
1 parent ffb349c commit 6e8ee87
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion python/taichi/lang/ast/ast_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def canonicalize_formatted_string(raw_string, *raw_args, **raw_keywords):

@staticmethod
def build_Call(ctx, node):
if ASTTransformer.get_decorator(ctx, node) == "static":
if ASTTransformer.get_decorator(ctx, node) in ["static", "static_assert"]:
with ctx.static_scope_guard():
build_stmt(ctx, node.func)
build_stmts(ctx, node.args)
Expand Down Expand Up @@ -1116,6 +1116,7 @@ def get_decorator(ctx, node):
return ""
for wanted, name in [
(impl.static, "static"),
(impl.static_assert, "static_assert"),
(impl.grouped, "grouped"),
(ndrange, "ndrange"),
]:
Expand Down

0 comments on commit 6e8ee87

Please sign in to comment.