diff --git a/dace/frontend/python/newast.py b/dace/frontend/python/newast.py index 1d1294809c..e6f9247157 100644 --- a/dace/frontend/python/newast.py +++ b/dace/frontend/python/newast.py @@ -303,7 +303,7 @@ def repl_callback(repldict): # Extra AST node types that are disallowed after preprocessing _DISALLOWED_STMTS = DISALLOWED_STMTS + [ 'Global', 'Assert', 'Print', 'Nonlocal', 'Raise', 'Starred', 'AsyncFor', 'ListComp', 'GeneratorExp', 'SetComp', - 'DictComp', 'comprehension' + 'DictComp', 'comprehension', 'TypeAlias' ] TaskletType = Union[ast.FunctionDef, ast.With, ast.For] @@ -4712,6 +4712,9 @@ def visit_Dict(self, node: ast.Dict): def visit_Lambda(self, node: ast.Lambda): # Return a string representation of the function return astutils.unparse(node) + + def visit_TypeAlias(self, node: ast.TypeAlias): + raise NotImplementedError('Type aliases are not supported in DaCe') ############################################################ diff --git a/tests/python_frontend/type_statement_test.py b/tests/python_frontend/type_statement_test.py new file mode 100644 index 0000000000..bdd168a158 --- /dev/null +++ b/tests/python_frontend/type_statement_test.py @@ -0,0 +1,19 @@ +# Copyright 2019-2023 ETH Zurich and the DaCe authors. All rights reserved. +import dace +import pytest + + +def test_type_statement(): + + @dace.program + def type_statement(): + type Scalar[T] = T + A: Scalar[dace.float32] = 0 + return A + + with pytest.raises(dace.frontend.python.common.DaceSyntaxError): + type_statement() + + +if __name__ == '__main__': + test_type_statement()