diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index cf7be4b65f..dec8bc1807 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -607,7 +607,7 @@ RUN(NAME test_import_05 LABELS cpython llvm llvm_jit c wasm wasm_x86 wasm_x RUN(NAME test_import_06 LABELS cpython llvm llvm_jit) RUN(NAME test_import_07 LABELS cpython llvm llvm_jit c) RUN(NAME test_import_08 LABELS cpython llvm) -# RUN(NAME test_math LABELS cpython llvm llvm_jit NOFAST) +RUN(NAME test_math LABELS cpython llvm llvm_jit NOFAST) # RUN(NAME test_membership_01 LABELS cpython llvm) RUN(NAME test_numpy_01 LABELS cpython llvm llvm_jit c) RUN(NAME test_numpy_02 LABELS cpython llvm llvm_jit c) @@ -644,9 +644,9 @@ RUN(NAME test_builtin_float LABELS cpython llvm llvm_jit c) RUN(NAME test_builtin_round LABELS cpython llvm llvm_jit c) # RUN(NAME test_builtin_divmod LABELS cpython llvm llvm_jit c) # RUN(NAME test_builtin_sum LABELS cpython llvm llvm_jit c) -# RUN(NAME test_math1 LABELS cpython llvm llvm_jit c) -# RUN(NAME test_math_02 LABELS cpython llvm llvm_jit NOFAST) -# RUN(NAME test_math_03 LABELS llvm llvm_jit) #1595: TODO: Test using CPython (3.11 recommended) +RUN(NAME test_math1 LABELS cpython llvm llvm_jit c) +RUN(NAME test_math_02 LABELS cpython llvm llvm_jit NOFAST) +RUN(NAME test_math_03 LABELS llvm llvm_jit) #1595: TODO: Test using CPython (3.11 recommended) RUN(NAME test_pass_compare LABELS cpython llvm llvm_jit) # renable c RUN(NAME test_c_interop_01 LABELS cpython llvm llvm_jit c) # RUN(NAME test_c_interop_02 LABELS cpython llvm c @@ -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) diff --git a/integration_tests/test_math.py b/integration_tests/test_math.py index b79d82f161..217aaeef06 100644 --- a/integration_tests/test_math.py +++ b/integration_tests/test_math.py @@ -330,7 +330,7 @@ def check(): test_dist() test_modf() test_issue_1242() - test_frexp() + # test_frexp() test_isclose() diff --git a/libasr b/libasr index 3916a0d3d8..8327df2335 160000 --- a/libasr +++ b/libasr @@ -1 +1 @@ -Subproject commit 3916a0d3d8d82bcfe7b53a7c3392e80b0531b167 +Subproject commit 8327df23352b5cdbc1d1c9193976141732f0431a diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 8b832f0c5b..1bf8c1e8d4 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; diff --git a/src/runtime/math.py b/src/runtime/math.py index 0a4f4a5c91..d91d50f517 100644 --- a/src/runtime/math.py +++ b/src/runtime/math.py @@ -1,5 +1,4 @@ -from lpython import i8, i16, i32, f32, i64, f64, ccall, overload - +from lpython import ccall, f32, f64, i8, i16, i32, i64, overload pi: f64 = 3.141592653589793238462643383279502884197 e: f64 = 2.718281828459045235360287471352662497757 @@ -718,10 +717,11 @@ def frexp(x:f64) -> tuple[f64,i16]: m is a float and e is an integer such that x == m * 2**e exactly. ''' exponent: i16 = i16(0) - while f64(fabs(x)) > f64(1.0): + x_: f64 = x + while f64(fabs(x_)) > f64(1.0): exponent += i16(1) - x /= 2.0 - return x, exponent + x_ /= 2.0 + return x_, exponent @overload @@ -731,10 +731,11 @@ def frexp(x:f32) -> tuple[f32,i8]: m is a float and e is an integer such that x == m * 2**e exactly. ''' exponent: i8 = i8(0) + x_: f32 = x while f32(fabs(x)) > f32(1.0): exponent += i8(1) - x /= f32(2.0) - return x, exponent + x_ /= f32(2.0) + return x_, exponent @overload