Skip to content

Commit

Permalink
Disallowing type aliases.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexnick83 committed Oct 9, 2023
1 parent fead1d6 commit e5c6451
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dace/frontend/python/newast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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')

############################################################

Expand Down
19 changes: 19 additions & 0 deletions tests/python_frontend/type_statement_test.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit e5c6451

Please sign in to comment.