diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index c9e12e97a6..3178636e29 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -722,6 +722,7 @@ RUN(NAME global_syms_06 LABELS cpython llvm c) RUN(NAME callback_01 LABELS cpython llvm c) RUN(NAME callback_02 LABELS cpython llvm c) +RUN(NAME callback_03 LABELS cpython llvm c) # Intrinsic Functions RUN(NAME intrinsics_01 LABELS cpython llvm NOFAST) # any diff --git a/integration_tests/callback_03.py b/integration_tests/callback_03.py new file mode 100644 index 0000000000..0f1f62e722 --- /dev/null +++ b/integration_tests/callback_03.py @@ -0,0 +1,13 @@ +from lpython import i32, Callable + +def foo(x : i32) -> None: + print(x) + assert x == 3 + +def bar(func : Callable[[i32], None], arg : i32) -> i32: + func(arg) + +def main0(): + bar(foo, 3) + +main0() diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index c4466d2bd7..ac31a64003 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -1703,6 +1703,10 @@ class CommonVisitor : public AST::BaseVisitor { abi, is_argument); } + if (AST::is_a(annotation)) { + return nullptr; + } + if (AST::is_a(annotation)) { AST::Subscript_t *s = AST::down_cast(&annotation); if (AST::is_a(*s->m_value)) {