diff --git a/integration_tests/test_generics_01.py b/integration_tests/test_generics_01.py index 2613f5eaeb..032f30c8e6 100644 --- a/integration_tests/test_generics_01.py +++ b/integration_tests/test_generics_01.py @@ -1,7 +1,8 @@ from overload_testing import foo, test -from ltypes import overload, i32 +from ltypes import overload, i32, i64 import overload_testing2 + @overload def foo1(a: i32, b: i32) -> i32: return a-b @@ -14,6 +15,7 @@ def foo1(a: i32) -> i32: def foo1(a: str) -> str: return "lpython-is-fun-" + a + @overload def test1(a: i32) -> i32: return a + 20 @@ -25,6 +27,19 @@ def test1(a: bool) -> i32: return -20 +@overload +def add(a: i32): + print(a) + +@overload +def add(a: i32, b: i32): + print(a + b) + +@overload +def add(a: i32, b: i64): + print(a + b) + + def check(): assert foo(2) == 4 assert foo1(2) == 16 @@ -41,5 +56,11 @@ def check(): assert test(False) == -test(True) and test(True) == 10 assert test1(False) == -test1(True) and test1(True) == 20 assert overload_testing2.test2(True) == 30 + # We are testing the subroutine using print to test it actually works + add(1, 2) + add(3) + i: i64 + i = 10 + add(2, i) check() diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 62156b84e0..51e8b5b219 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -2560,8 +2560,8 @@ class BodyVisitor : public CommonVisitor { throw SemanticError("Function '" + call_name + "' is not declared", x.base.base.loc); } - tmp = ASR::make_SubroutineCall_t(al, x.base.base.loc, s, - nullptr, args.p, args.size(), nullptr); + tmp = make_call_helper(al, s, current_scope, args, call_name, + x.base.base.loc); return; } this->visit_expr(*x.m_value);