diff --git a/integration_tests/lpython_decorator_02.py b/integration_tests/lpython_decorator_02.py index 423243f7cd..31cb14c6ba 100644 --- a/integration_tests/lpython_decorator_02.py +++ b/integration_tests/lpython_decorator_02.py @@ -1,5 +1,5 @@ from numpy import array -from lpython import i32, i64, f64, lpython, TypeVar +from lpython import i32, i64, f64, lpython, TypeVar, Const n = TypeVar("n") @@ -17,6 +17,10 @@ def multiply_02(n: i32, x: i64[:], y: i64[:]) -> i64[n]: z[i] = x[i] * y[i] return z +@lpython +def const_arg_sum(x: Const[i32]) -> i32: + return 10 + x + def test_01(): size = 5 @@ -30,5 +34,6 @@ def test_01(): z = multiply_02(size, x, y) for i in range(size): assert z[i] == x[i] * y[i] + assert const_arg_sum(size) == size + 10 test_01() diff --git a/src/libasr/codegen/asr_to_c_cpp.h b/src/libasr/codegen/asr_to_c_cpp.h index ef718db8f6..48f0d8df94 100644 --- a/src/libasr/codegen/asr_to_c_cpp.h +++ b/src/libasr/codegen/asr_to_c_cpp.h @@ -694,6 +694,8 @@ R"(#include } } case ASR::ttypeType::Logical : { return "p"; + } case ASR::ttypeType::Const : { + return get_type_format(ASR::down_cast(type)->m_type); } case ASR::ttypeType::Array : { return "O"; } default: {