Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions integration_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions integration_tests/callback_03.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions src/lpython/semantics/python_ast_to_asr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,10 @@ class CommonVisitor : public AST::BaseVisitor<Struct> {
abi, is_argument);
}

if (AST::is_a<AST::ConstantNone_t>(annotation)) {
return nullptr;
}

if (AST::is_a<AST::Subscript_t>(annotation)) {
AST::Subscript_t *s = AST::down_cast<AST::Subscript_t>(&annotation);
if (AST::is_a<AST::Name_t>(*s->m_value)) {
Expand Down