From bc8bfea367351b71f515276aee5e1cfacea781ce Mon Sep 17 00:00:00 2001 From: swamishiju Date: Sun, 13 Apr 2025 11:52:03 +0530 Subject: [PATCH 1/4] Optional args fixed --- src/lpython/semantics/python_ast_to_asr.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 8b832f0c5b..c03828afdc 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -1178,7 +1178,7 @@ class CommonVisitor : public AST::BaseVisitor { size_t missed_args_count =0; for (size_t def_arg = args.size(); def_arg < func->n_args; def_arg++){ ASR::Variable_t* var = ASRUtils::EXPR2VAR(func->m_args[def_arg]); - if(var->m_symbolic_value == nullptr) { + if(var->m_presence != ASR::presenceType::Optional) { missed_args_names+= "'" + std::string(var->m_name) + "' and "; missed_args_count++; } else { @@ -4570,7 +4570,8 @@ class SymbolTableVisitor : public CommonVisitor { std::string arg_s = arg; ASR::expr_t *value = nullptr; ASR::expr_t *init_expr = nullptr; - if (i >= default_arg_index_start){ + bool is_optional_arg = i >= default_arg_index_start; + if (is_optional_arg){ size_t default_arg_index = i - default_arg_index_start; this->visit_expr(*(x.m_args.m_defaults[default_arg_index])); init_expr = ASRUtils::EXPR(tmp); @@ -4593,7 +4594,7 @@ class SymbolTableVisitor : public CommonVisitor { } ASR::accessType s_access = ASR::accessType::Public; ASR::presenceType s_presence = ASR::presenceType::Required; - if (i >= default_arg_index_start){ + if (is_optional_arg){ s_presence = ASR::presenceType::Optional; } bool value_attr = false; From 47e1937453662262bfc488912ff84459dbb931d7 Mon Sep 17 00:00:00 2001 From: swamishiju Date: Sun, 13 Apr 2025 11:57:53 +0530 Subject: [PATCH 2/4] Uncommented test --- integration_tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index cf7be4b65f..c4f5c7a3ae 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -805,7 +805,7 @@ RUN(NAME test_statistics_01 LABELS cpython llvm llvm_jit NOFAST) RUN(NAME test_attributes LABELS cpython llvm llvm_jit) # RUN(NAME test_str_attributes LABELS cpython llvm llvm_jit c) RUN(NAME kwargs_01 LABELS cpython llvm llvm_jit NOFAST) # renable c -# RUN(NAME def_func_01 LABELS cpython llvm llvm_jit c) +RUN(NAME def_func_01 LABELS cpython llvm llvm_jit c) RUN(NAME func_inline_01 LABELS llvm llvm_jit c wasm) RUN(NAME func_inline_02 LABELS cpython llvm llvm_jit c) From 92b0bea681c71a08b77ef6aa3012f9706319bc0c Mon Sep 17 00:00:00 2001 From: swamishiju Date: Tue, 15 Apr 2025 05:12:07 +0530 Subject: [PATCH 3/4] Optional args --- libasr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libasr b/libasr index 4a52ccea1b..df83d90fdf 160000 --- a/libasr +++ b/libasr @@ -1 +1 @@ -Subproject commit 4a52ccea1b6157a259ac478bd84477d119d4adbd +Subproject commit df83d90fdf7d61c56abddb2643328c7cc9a0ebb1 From 7cdf09c2f90fabd834fcb80c25da918744dc5333 Mon Sep 17 00:00:00 2001 From: swamishiju Date: Tue, 15 Apr 2025 05:39:27 +0530 Subject: [PATCH 4/4] Disabled C for def_dunc_01 --- integration_tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index c4f5c7a3ae..eb4e34dc83 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -805,7 +805,7 @@ RUN(NAME test_statistics_01 LABELS cpython llvm llvm_jit NOFAST) RUN(NAME test_attributes LABELS cpython llvm llvm_jit) # RUN(NAME test_str_attributes LABELS cpython llvm llvm_jit c) RUN(NAME kwargs_01 LABELS cpython llvm llvm_jit NOFAST) # renable c -RUN(NAME def_func_01 LABELS cpython llvm llvm_jit c) +RUN(NAME def_func_01 LABELS cpython llvm llvm_jit) # renable c RUN(NAME func_inline_01 LABELS llvm llvm_jit c wasm) RUN(NAME func_inline_02 LABELS cpython llvm llvm_jit c)