From 65bf0f1d03ae37ea71f91f49dad160426b4dfec7 Mon Sep 17 00:00:00 2001 From: swamishiju Date: Thu, 8 Jan 2026 22:56:45 +0530 Subject: [PATCH 1/3] CHORE: Updated compiler options --- libasr | 2 +- src/bin/lpython.cpp | 4 ---- src/lpython/python_evaluator.cpp | 13 ------------ src/lpython/python_kernel.cpp | 1 - src/lpython/tests/test_llvm.cpp | 35 -------------------------------- 5 files changed, 1 insertion(+), 54 deletions(-) diff --git a/libasr b/libasr index f2a04fc2ae..e84b66d34e 160000 --- a/libasr +++ b/libasr @@ -1 +1 @@ -Subproject commit f2a04fc2ae4dd9ccb940c0fee3f694791fec7005 +Subproject commit e84b66d34ecc4a8b85477cbc3899ecb667ed7d4a diff --git a/src/bin/lpython.cpp b/src/bin/lpython.cpp index 573a5a9658..814f5d905c 100644 --- a/src/bin/lpython.cpp +++ b/src/bin/lpython.cpp @@ -1880,8 +1880,6 @@ int main(int argc, char *argv[]) // app.add_option("-J", arg_J, "Where to save mod files"); app.add_flag("--jit", to_jit, "Execute the program using just-in-time (JIT) compiler"); app.add_flag("-g", compiler_options.emit_debug_info, "Compile with debugging information"); - app.add_flag("--debug-with-line-column", compiler_options.emit_debug_line_column, - "Convert the linear location info into line + column in the debugging information"); // app.add_option("-D", compiler_options.c_preprocessor_defines, "Define = (or 1 if omitted)")->allow_extra_args(false); app.add_flag("--version", arg_version, "Display compiler version information"); @@ -2085,7 +2083,6 @@ int main(int argc, char *argv[]) lpython_pass_manager.parse_pass_arg(arg_pass, skip_pass); lpython_pass_manager.use_default_passes(); compiler_options.po.disable_main = true; - compiler_options.emit_debug_line_column = false; compiler_options.separate_compilation = false; return interactive_python_repl(lpython_pass_manager, compiler_options, arg_v); #else @@ -2225,7 +2222,6 @@ int main(int argc, char *argv[]) return 1; } compiler_options.emit_debug_info = false; - compiler_options.emit_debug_line_column = false; compiler_options.separate_compilation = false; return compile_python_using_llvm(arg_file, "", runtime_library_dir, lpython_pass_manager, compiler_options, time_report, false, true); diff --git a/src/lpython/python_evaluator.cpp b/src/lpython/python_evaluator.cpp index b9d59f22f8..34a85169b3 100644 --- a/src/lpython/python_evaluator.cpp +++ b/src/lpython/python_evaluator.cpp @@ -445,19 +445,6 @@ Result> PythonCompiler::get_llvm3( ) { #ifdef HAVE_LFORTRAN_LLVM - if (compiler_options.emit_debug_info) { - if (!compiler_options.emit_debug_line_column) { - diagnostics.add(LCompilers::diag::Diagnostic( - "The `emit_debug_line_column` is not enabled; please use the " - "`--debug-with-line-column` option to get the correct " - "location information", - LCompilers::diag::Level::Error, - LCompilers::diag::Stage::Semantic, {}) - ); - Error err; - return err; - } - } // ASR -> LLVM std::unique_ptr m; Result> res diff --git a/src/lpython/python_kernel.cpp b/src/lpython/python_kernel.cpp index 319466cff7..0793e6373c 100644 --- a/src/lpython/python_kernel.cpp +++ b/src/lpython/python_kernel.cpp @@ -79,7 +79,6 @@ namespace LCompilers::LPython { custom_interpreter() : e{CompilerOptions()} { e.compiler_options.interactive = true; e.compiler_options.po.disable_main = true; - e.compiler_options.emit_debug_line_column = false; e.compiler_options.separate_compilation = false; } virtual ~custom_interpreter() = default; diff --git a/src/lpython/tests/test_llvm.cpp b/src/lpython/tests/test_llvm.cpp index 599161b937..1e9388fb46 100644 --- a/src/lpython/tests/test_llvm.cpp +++ b/src/lpython/tests/test_llvm.cpp @@ -612,7 +612,6 @@ define float @f() TEST_CASE("PythonCompiler 1") { CompilerOptions cu; cu.po.disable_main = true; - cu.emit_debug_line_column = false; cu.separate_compilation = false; cu.interactive = true; cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -627,7 +626,6 @@ TEST_CASE("PythonCompiler 1") { // TEST_CASE("PythonCompiler 2") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -646,7 +644,6 @@ TEST_CASE("PythonCompiler 1") { TEST_CASE("PythonCompiler i32 expressions") { CompilerOptions cu; cu.po.disable_main = true; - cu.emit_debug_line_column = false; cu.separate_compilation = false; cu.interactive = true; cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -692,7 +689,6 @@ TEST_CASE("PythonCompiler i32 expressions") { // TEST_CASE("PythonCompiler i32 declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -727,7 +723,6 @@ TEST_CASE("PythonCompiler i32 expressions") { TEST_CASE("PythonCompiler i64 expressions") { CompilerOptions cu; cu.po.disable_main = true; - cu.emit_debug_line_column = false; cu.separate_compilation = false; cu.interactive = true; cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -773,7 +768,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler i64 declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -808,7 +802,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler u32 expressions") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -854,7 +847,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler u32 declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -890,7 +882,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler u64 expressions") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -936,7 +927,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler u64 declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -971,7 +961,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler i8 expressions") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1017,7 +1006,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler i8 declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1052,7 +1040,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler u8 expressions") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1098,7 +1085,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler u8 declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1133,7 +1119,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler i16 expressions") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1179,7 +1164,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler i16 declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1214,7 +1198,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler u16 expressions") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1260,7 +1243,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler u16 declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1295,7 +1277,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler boolean expressions") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1326,7 +1307,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler boolean declaration") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1366,7 +1346,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler string 1") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1387,7 +1366,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler string 2") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1421,7 +1399,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler string 3") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1453,7 +1430,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler Array 1") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1470,7 +1446,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler lists") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1509,7 +1484,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler tuples") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1556,7 +1530,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler classes") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1663,7 +1636,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler underscore 1") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1694,7 +1666,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler underscore 2") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1743,7 +1714,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler underscore 3") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1776,7 +1746,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler underscore 4") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1809,7 +1778,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler asr verify 1") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1828,7 +1796,6 @@ TEST_CASE("PythonCompiler i64 expressions") { // TEST_CASE("PythonCompiler asr verify 2") { // CompilerOptions cu; // cu.po.disable_main = true; -// cu.emit_debug_line_column = false; // cu.separate_compilation = false; // cu.interactive = true; // cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1855,7 +1822,6 @@ TEST_CASE("PythonCompiler i64 expressions") { TEST_CASE("PythonCompiler asr verify 3") { CompilerOptions cu; cu.po.disable_main = true; - cu.emit_debug_line_column = false; cu.separate_compilation = false; cu.interactive = true; cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); @@ -1887,7 +1853,6 @@ def subi(x: i32, y: i32) -> i32: TEST_CASE("PythonCompiler asr verify 4") { CompilerOptions cu; cu.po.disable_main = true; - cu.emit_debug_line_column = false; cu.separate_compilation = false; cu.interactive = true; cu.po.runtime_library_dir = LCompilers::LPython::get_runtime_library_dir(); From 3894aa2a8073dd3475395c7807318749513773bd Mon Sep 17 00:00:00 2001 From: swamishiju Date: Thu, 8 Jan 2026 23:12:59 +0530 Subject: [PATCH 2/3] TEST: Updated tests --- tests/reference/asr-print_02-afbe092.json | 2 +- tests/reference/asr-print_02-afbe092.stdout | 28 +++-- tests/reference/asr-structs_09-f3ffe08.json | 4 +- tests/reference/asr-structs_09-f3ffe08.stderr | 28 ++++- .../asr-test_builtin_len-55b0dec.json | 2 +- .../asr-test_builtin_len-55b0dec.stdout | 8 +- tests/reference/asr-tuple1-09972ab.json | 2 +- tests/reference/asr-tuple1-09972ab.stdout | 40 +++++-- .../reference/c-variable_decl_03-fa1823b.json | 2 +- .../c-variable_decl_03-fa1823b.stdout | 15 +-- .../cpp-test_builtin_pow-56b3f92.json | 2 +- .../cpp-test_builtin_pow-56b3f92.stdout | 34 +++--- tests/reference/llvm_dbg-expr_01-9fc5f30.json | 10 +- .../reference/llvm_dbg-expr_01-9fc5f30.stderr | 2 + .../reference/llvm_dbg-expr_01-9fc5f30.stdout | 113 ------------------ ...ass_print_list_tuple-print_02-09600eb.json | 2 +- ...s_print_list_tuple-print_02-09600eb.stdout | 28 +++-- .../run_dbg-test_assert_01-2f34744.json | 4 +- .../run_dbg-test_assert_01-2f34744.stderr | 9 +- .../run_dbg-test_assert_03-bd7b7dd.json | 4 +- .../run_dbg-test_assert_03-bd7b7dd.stderr | 13 +- .../run_dbg-test_quit_01-30889cc.json | 4 +- .../run_dbg-test_quit_01-30889cc.stderr | 9 +- .../run_dbg-test_raise_01-dfd86ca.json | 4 +- .../run_dbg-test_raise_01-dfd86ca.stderr | 9 +- tests/reference/wat-bool1-234bcd1.json | 2 +- tests/reference/wat-bool1-234bcd1.stdout | 12 +- tests/reference/wat-expr14-5e0cb96.json | 2 +- tests/reference/wat-expr14-5e0cb96.stdout | 12 +- tests/reference/wat-expr2-8b17723.json | 2 +- tests/reference/wat-expr2-8b17723.stdout | 12 +- tests/reference/wat-print_str-385e953.json | 2 +- tests/reference/wat-print_str-385e953.stdout | 12 +- 33 files changed, 183 insertions(+), 251 deletions(-) create mode 100644 tests/reference/llvm_dbg-expr_01-9fc5f30.stderr delete mode 100644 tests/reference/llvm_dbg-expr_01-9fc5f30.stdout diff --git a/tests/reference/asr-print_02-afbe092.json b/tests/reference/asr-print_02-afbe092.json index 007f14f3e2..fe016bb6c2 100644 --- a/tests/reference/asr-print_02-afbe092.json +++ b/tests/reference/asr-print_02-afbe092.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-print_02-afbe092.stdout", - "stdout_hash": "81b28e9c321e4c2f5c4979702be9155fdb7a0bbe0044b34470a55926", + "stdout_hash": "fc8a85b6bc8901fcbbd9bccf807cf6927c9cb26760942c2db6c55491", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-print_02-afbe092.stdout b/tests/reference/asr-print_02-afbe092.stdout index 5fd1be62f2..a183a31cf3 100644 --- a/tests/reference/asr-print_02-afbe092.stdout +++ b/tests/reference/asr-print_02-afbe092.stdout @@ -3037,7 +3037,9 @@ )] (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) (TupleConstant @@ -3048,13 +3050,17 @@ )] (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) )] (List (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) ) @@ -3067,7 +3073,9 @@ )] (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) (TupleConstant @@ -3078,13 +3086,17 @@ )] (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) )] (List (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) )] @@ -3092,7 +3104,9 @@ (List (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) ) diff --git a/tests/reference/asr-structs_09-f3ffe08.json b/tests/reference/asr-structs_09-f3ffe08.json index a27b365565..8f306ed10c 100644 --- a/tests/reference/asr-structs_09-f3ffe08.json +++ b/tests/reference/asr-structs_09-f3ffe08.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "asr-structs_09-f3ffe08.stderr", - "stderr_hash": "14119a0bc6420ad242b99395d457f2092014d96d2a1ac81d376c649d", - "returncode": 2 + "stderr_hash": "b37b8fa37881df2189147ce1d10d155f0d770374a0ebd9a9cbf312a8", + "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/asr-structs_09-f3ffe08.stderr b/tests/reference/asr-structs_09-f3ffe08.stderr index a67cb70dba..a8c7fdc37d 100644 --- a/tests/reference/asr-structs_09-f3ffe08.stderr +++ b/tests/reference/asr-structs_09-f3ffe08.stderr @@ -1,5 +1,23 @@ -semantic error: Method not found in the class StringIO or it's parents - --> tests/errors/structs_09.py:13:23 - | -13 | bytes_read: i32 = fd.read() - | ^^^^^^^^^ +Internal Compiler Error: Unhandled exception +Traceback (most recent call last): + File "$DIR/lpython.cpp", line 2142 + File "$DIR/lpython.cpp", line 216 + File "$DIR/semantics/python_ast_to_asr.cpp", line 9188 + File "$DIR/semantics/python_ast_to_asr.cpp", line 9120 + File "$DIR/semantics/python_ast_to_asr.cpp", line 5204 + File "$DIR/python_ast.h", line 1909 + File "$DIR/python_ast.h", line 1776 + File "$DIR/semantics/python_ast_to_asr.cpp", line 5394 + File "$DIR/semantics/python_ast_to_asr.cpp", line 5370 + File "$DIR/semantics/python_ast_to_asr.cpp", line 5158 + File "$DIR/python_ast.h", line 1909 + File "$DIR/python_ast.h", line 1782 + File "$DIR/semantics/python_ast_to_asr.cpp", line 5466 + File "$DIR/semantics/python_ast_to_asr.cpp", line 2898 + File "$DIR/python_ast.h", line 1936 + File "$DIR/python_ast.h", line 1825 + File "$DIR/semantics/python_ast_to_asr.cpp", line 8505 + File "$DIR/semantics/python_ast_to_asr.cpp", line 8245 + File "$DIR/libasr/src/libasr/containers.h", line 164 + LCOMPILERS_ASSERT(pos < n); +AssertFailed: pos < n diff --git a/tests/reference/asr-test_builtin_len-55b0dec.json b/tests/reference/asr-test_builtin_len-55b0dec.json index 3961952d18..2ce93cdbec 100644 --- a/tests/reference/asr-test_builtin_len-55b0dec.json +++ b/tests/reference/asr-test_builtin_len-55b0dec.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-test_builtin_len-55b0dec.stdout", - "stdout_hash": "b2cd8402abe2c03cfa658d19260d285f3dc391c36e793b6e004f5005", + "stdout_hash": "ddc8d9fe739311a02fa1ea239a40fdcf421fce2f37e3a3168b30d649", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-test_builtin_len-55b0dec.stdout b/tests/reference/asr-test_builtin_len-55b0dec.stdout index ccb509e32e..a3e802e4d3 100644 --- a/tests/reference/asr-test_builtin_len-55b0dec.stdout +++ b/tests/reference/asr-test_builtin_len-55b0dec.stdout @@ -564,7 +564,9 @@ (Tuple [(Integer 4) (Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) () @@ -612,7 +614,9 @@ [(Real 8) (Logical 4) (Logical 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) + (Allocatable + (String 1 () DeferredLength DescriptorString) + ) (Integer 4)] ) ) diff --git a/tests/reference/asr-tuple1-09972ab.json b/tests/reference/asr-tuple1-09972ab.json index e2bdb85de0..1c95456024 100644 --- a/tests/reference/asr-tuple1-09972ab.json +++ b/tests/reference/asr-tuple1-09972ab.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-tuple1-09972ab.stdout", - "stdout_hash": "639c2cc9a9a6db4f961bdee39fdaff3b85a4dda684ac62a51315fbc9", + "stdout_hash": "978639d2781799e9f2905a4041f206549c7fbee9f7bad0c35d8f6a6d", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-tuple1-09972ab.stdout b/tests/reference/asr-tuple1-09972ab.stdout index dda49d62f8..f84baf9576 100644 --- a/tests/reference/asr-tuple1-09972ab.stdout +++ b/tests/reference/asr-tuple1-09972ab.stdout @@ -397,9 +397,15 @@ (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) )] (Tuple - [(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + [(Allocatable + (String 1 () DeferredLength DescriptorString) + ) + (Allocatable + (String 1 () DeferredLength DescriptorString) + ) + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) () @@ -446,7 +452,9 @@ [(Integer 4) (Integer 4) (Real 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) () @@ -543,8 +551,12 @@ ) (Var 3 float_mem1)] (Tuple - [(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) + [(Allocatable + (String 1 () DeferredLength DescriptorString) + ) + (Allocatable + (String 1 () DeferredLength DescriptorString) + ) (Real 4)] ) ) @@ -556,19 +568,27 @@ (IntegerConstant 3 (Integer 4) Decimal) (Var 3 float_mem2)] (Tuple - [(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) + [(Allocatable + (String 1 () DeferredLength DescriptorString) + ) (Integer 4) (Real 4)] ) )] (Tuple [(Tuple - [(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) + [(Allocatable + (String 1 () DeferredLength DescriptorString) + ) + (Allocatable + (String 1 () DeferredLength DescriptorString) + ) (Real 4)] ) (Tuple - [(String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString) + [(Allocatable + (String 1 () DeferredLength DescriptorString) + ) (Integer 4) (Real 4)] )] diff --git a/tests/reference/c-variable_decl_03-fa1823b.json b/tests/reference/c-variable_decl_03-fa1823b.json index 1060de968b..c7fc823e54 100644 --- a/tests/reference/c-variable_decl_03-fa1823b.json +++ b/tests/reference/c-variable_decl_03-fa1823b.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "c-variable_decl_03-fa1823b.stdout", - "stdout_hash": "b8397cdd7e8998d29574393db30b5638aedd2ecd34a596b8b1c29f7f", + "stdout_hash": "06db4b8826af45ad804274d183e41047f7f34ba719ec5e9b771679bb", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/c-variable_decl_03-fa1823b.stdout b/tests/reference/c-variable_decl_03-fa1823b.stdout index 7c25386e04..d8e75abe72 100644 --- a/tests/reference/c-variable_decl_03-fa1823b.stdout +++ b/tests/reference/c-variable_decl_03-fa1823b.stdout @@ -1,3 +1,4 @@ +#include #include #include @@ -5,7 +6,6 @@ #include #include -double _lcompilers_abs_f64(double x); double f(); void _xx_lcompilers_changed_main_xx(); void __main__global_stmts(); @@ -13,17 +13,6 @@ void __main__global_stmts(); // Implementations -double _lcompilers_abs_f64(double x) -{ - double _lcompilers_abs_f64; - if (x >= 0.00000000000000000e+00) { - _lcompilers_abs_f64 = x; - } else { - _lcompilers_abs_f64 = -x; - } - return _lcompilers_abs_f64; -} - double f() { double _lpython_return_variable; @@ -36,7 +25,7 @@ void _xx_lcompilers_changed_main_xx() double t1; t1 = f()* 1.00000000000000000e+06; printf("%lf\n", t1); - ASSERT(_lcompilers_abs_f64(t1 - 5.50000000000000000e+00* 1.00000000000000000e+06) <= 9.99999999999999955e-07); + ASSERT(fabs(t1 - 5.50000000000000000e+00* 1.00000000000000000e+06) <= 9.99999999999999955e-07); } void __main__global_stmts() diff --git a/tests/reference/cpp-test_builtin_pow-56b3f92.json b/tests/reference/cpp-test_builtin_pow-56b3f92.json index 8d267d3b66..b5898753c3 100644 --- a/tests/reference/cpp-test_builtin_pow-56b3f92.json +++ b/tests/reference/cpp-test_builtin_pow-56b3f92.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "cpp-test_builtin_pow-56b3f92.stdout", - "stdout_hash": "6e1fbf9ddf9a5d58571177561591e443768bd4b3fc777ec390fc1537", + "stdout_hash": "80b231933a8541deb4c7ce3e9e1b06144fbe21d25750558e393810d0", "stderr": "cpp-test_builtin_pow-56b3f92.stderr", "stderr_hash": "859ce76c74748f2d32c7eab92cfbba789a78d4cbf5818646b99806ea", "returncode": 0 diff --git a/tests/reference/cpp-test_builtin_pow-56b3f92.stdout b/tests/reference/cpp-test_builtin_pow-56b3f92.stdout index 8e5bf7278b..cecaaff386 100644 --- a/tests/reference/cpp-test_builtin_pow-56b3f92.stdout +++ b/tests/reference/cpp-test_builtin_pow-56b3f92.stdout @@ -191,26 +191,26 @@ void test_pow() assert (__lpython_overloaded_8__pow(false, false) == 1); a1 = 4.50000000000000000e+00; a2 = 2.29999999999999982e+00; - assert (abs(__lpython_overloaded_3__pow(a1, a2) - 3.17971929089206000e+01) < eps); - assert (abs(__lpython_overloaded_3__pow(a2, a1) - 4.24399889427765871e+01) < eps); + assert (fabs(__lpython_overloaded_3__pow(a1, a2) - 3.17971929089206000e+01) < eps); + assert (fabs(__lpython_overloaded_3__pow(a2, a1) - 4.24399889427765871e+01) < eps); x = 3; y = 2.29999999999999982e+00; - assert (abs(__lpython_overloaded_6__pow(x, y) - 1.25135025328431819e+01) < eps); - assert (abs(__lpython_overloaded_7__pow(y, x) - 1.21669999999999980e+01) < eps); - assert (abs(__lpython_overloaded_6__pow(x, 5.50000000000000000e+00) - 4.20888346239237194e+02) < eps); - assert (abs(__lpython_overloaded_1__pow(2, -1) - 5.00000000000000000e-01) < eps); - assert (abs(__lpython_overloaded_1__pow(6, -4) - 7.71604938271604895e-04) < eps); - assert (abs(__lpython_overloaded_1__pow(-3, -5) + 4.11522633744856002e-03) < eps); - assert (abs(__lpython_overloaded_1__pow(6, -4) - 7.71604938271604895e-04) < eps); - assert (abs(__lpython_overloaded_3__pow( 4.50000000000000000e+00, 2.29999999999999982e+00) - 3.17971929089206000e+01) < eps); - assert (abs(__lpython_overloaded_3__pow( 2.29999999999999982e+00, 0.00000000000000000e+00) - 1.00000000000000000e+00) < eps); - assert (abs(__lpython_overloaded_3__pow( 2.29999999999999982e+00, - 1.50000000000000000e+00) - 2.86687162345994395e-01) < eps); - assert (abs(__lpython_overloaded_6__pow(2, 3.39999999999999991e+00) - 1.05560632861831536e+01) < eps); - assert (abs(__lpython_overloaded_6__pow(2, - 3.39999999999999991e+00) - 9.47322854068998882e-02) < eps); - assert (abs(__lpython_overloaded_7__pow( 3.39999999999999991e+00, 9) - 6.07169927664639836e+04) < eps); - assert (abs(__lpython_overloaded_7__pow( 0.00000000000000000e+00, 53) - 0.00000000000000000e+00) < eps); + assert (fabs(__lpython_overloaded_6__pow(x, y) - 1.25135025328431819e+01) < eps); + assert (fabs(__lpython_overloaded_7__pow(y, x) - 1.21669999999999980e+01) < eps); + assert (fabs(__lpython_overloaded_6__pow(x, 5.50000000000000000e+00) - 4.20888346239237194e+02) < eps); + assert (fabs(__lpython_overloaded_1__pow(2, -1) - 5.00000000000000000e-01) < eps); + assert (fabs(__lpython_overloaded_1__pow(6, -4) - 7.71604938271604895e-04) < eps); + assert (fabs(__lpython_overloaded_1__pow(-3, -5) + 4.11522633744856002e-03) < eps); + assert (fabs(__lpython_overloaded_1__pow(6, -4) - 7.71604938271604895e-04) < eps); + assert (fabs(__lpython_overloaded_3__pow( 4.50000000000000000e+00, 2.29999999999999982e+00) - 3.17971929089206000e+01) < eps); + assert (fabs(__lpython_overloaded_3__pow( 2.29999999999999982e+00, 0.00000000000000000e+00) - 1.00000000000000000e+00) < eps); + assert (fabs(__lpython_overloaded_3__pow( 2.29999999999999982e+00, - 1.50000000000000000e+00) - 2.86687162345994395e-01) < eps); + assert (fabs(__lpython_overloaded_6__pow(2, 3.39999999999999991e+00) - 1.05560632861831536e+01) < eps); + assert (fabs(__lpython_overloaded_6__pow(2, - 3.39999999999999991e+00) - 9.47322854068998882e-02) < eps); + assert (fabs(__lpython_overloaded_7__pow( 3.39999999999999991e+00, 9) - 6.07169927664639836e+04) < eps); + assert (fabs(__lpython_overloaded_7__pow( 0.00000000000000000e+00, 53) - 0.00000000000000000e+00) < eps); assert ((int32_t)(__lpython_overloaded_0__pow(4, 2)) == 16); - assert (abs(__lpython_overloaded_7__pow(- 4.23500000000000000e+03, 52) - 3.94800380598526379e+188) < eps); + assert (fabs(__lpython_overloaded_7__pow(- 4.23500000000000000e+03, 52) - 3.94800380598526379e+188) < eps); i = 7; j = 2; k = 5; diff --git a/tests/reference/llvm_dbg-expr_01-9fc5f30.json b/tests/reference/llvm_dbg-expr_01-9fc5f30.json index e541634d02..1752d17f89 100644 --- a/tests/reference/llvm_dbg-expr_01-9fc5f30.json +++ b/tests/reference/llvm_dbg-expr_01-9fc5f30.json @@ -5,9 +5,9 @@ "infile_hash": "4284fe3a1b4dd3e5d1de1357a79e9a25b426ca245b4cc91cf99e8547", "outfile": null, "outfile_hash": null, - "stdout": "llvm_dbg-expr_01-9fc5f30.stdout", - "stdout_hash": "bfee947cdf74468b9ae47a79c4f93a36d2dea1d313029b7bd7b7b7ca", - "stderr": null, - "stderr_hash": null, - "returncode": 0 + "stdout": null, + "stdout_hash": null, + "stderr": "llvm_dbg-expr_01-9fc5f30.stderr", + "stderr_hash": "00ddc89bd7b49589d524136cdf56c9b4d7661cab8637dc18c947809a", + "returncode": 109 } \ No newline at end of file diff --git a/tests/reference/llvm_dbg-expr_01-9fc5f30.stderr b/tests/reference/llvm_dbg-expr_01-9fc5f30.stderr new file mode 100644 index 0000000000..c4f4d77f69 --- /dev/null +++ b/tests/reference/llvm_dbg-expr_01-9fc5f30.stderr @@ -0,0 +1,2 @@ +The following argument was not expected: --debug-with-line-column +Run with --help for more information. diff --git a/tests/reference/llvm_dbg-expr_01-9fc5f30.stdout b/tests/reference/llvm_dbg-expr_01-9fc5f30.stdout deleted file mode 100644 index 6c1b3935a1..0000000000 --- a/tests/reference/llvm_dbg-expr_01-9fc5f30.stdout +++ /dev/null @@ -1,113 +0,0 @@ -; ModuleID = 'LFortran' -source_filename = "LFortran" - -%string_descriptor = type <{ i8*, i64 }> - -@0 = private unnamed_addr constant [2 x i8] c"\0A\00", align 1 -@serialization_info = private unnamed_addr constant [3 x i8] c"I4\00", align 1 -@1 = private unnamed_addr constant [5 x i8] c"%s%s\00", align 1 - -define void @__module___main_____main__global_stmts() !dbg !3 { -.entry: - call void @__module___main___main0(), !dbg !6 - br label %return, !dbg !6 - -return: ; preds = %.entry - br label %FINALIZE_SYMTABLE___main__global_stmts, !dbg !6 - -FINALIZE_SYMTABLE___main__global_stmts: ; preds = %return - ret void, !dbg !6 -} - -define void @__module___main___main0() !dbg !7 { -.entry: - %x = alloca i32, align 4, !dbg !8 - call void @llvm.dbg.declare(metadata i32* %x, metadata !9, metadata !DIExpression()), !dbg !11 - %x2 = alloca i64, align 8 - call void @llvm.dbg.declare(metadata i64* %x2, metadata !12, metadata !DIExpression()), !dbg !14 - %y = alloca float, align 4 - call void @llvm.dbg.declare(metadata float* %y, metadata !15, metadata !DIExpression()), !dbg !17 - %y2 = alloca double, align 8 - call void @llvm.dbg.declare(metadata double* %y2, metadata !18, metadata !DIExpression()), !dbg !20 - store i32 25, i32* %x, align 4, !dbg !21 - %0 = alloca i64, align 8, !dbg !21 - %1 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info, i32 0, i32 0), i64* %0, i32 0, i32 0, i32* %x), !dbg !21 - %2 = load i64, i64* %0, align 4, !dbg !21 - %stringFormat_desc = alloca %string_descriptor, align 8, !dbg !21 - %3 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 0, !dbg !21 - store i8* %1, i8** %3, align 8, !dbg !21 - %4 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 1, !dbg !21 - store i64 %2, i64* %4, align 4, !dbg !21 - %5 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 0, !dbg !21 - %6 = load i8*, i8** %5, align 8, !dbg !21 - %7 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc, i32 0, i32 1, !dbg !21 - %8 = load i64, i64* %7, align 4, !dbg !21 - %9 = trunc i64 %8 to i32, !dbg !21 - call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i8* %6, i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0), i32 1), !dbg !21 - call void @_lfortran_free(i8* %1), !dbg !21 - br label %return, !dbg !21 - -return: ; preds = %.entry - br label %FINALIZE_SYMTABLE_main0, !dbg !21 - -FINALIZE_SYMTABLE_main0: ; preds = %return - ret void, !dbg !21 -} - -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 - -declare i8* @_lcompilers_string_format_fortran(i8*, i64, i8*, i64*, i32, i32, ...) - -declare void @_lfortran_printf(i8*, i8*, i32, i8*, i32) - -declare void @_lfortran_free(i8*) - -define i32 @main(i32 %0, i8** %1) !dbg !22 { -.entry: - call void @_lpython_call_initial_functions(i32 %0, i8** %1), !dbg !25 - call void @__module___main_____main__global_stmts(), !dbg !25 - call void @_lpython_free_argv(), !dbg !25 - br label %return, !dbg !25 - -return: ; preds = %.entry - br label %FINALIZE_SYMTABLE_main_program, !dbg !25 - -FINALIZE_SYMTABLE_main_program: ; preds = %return - ret i32 0, !dbg !25 -} - -declare void @_lpython_call_initial_functions(i32, i8**) - -declare void @_lpython_free_argv() - -attributes #0 = { nounwind readnone speculatable willreturn } - -!llvm.dbg.cu = !{!0} - -!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "LPython Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) -!1 = !DIFile(filename: "tests/expr_01.py", directory: ".") -!2 = !{} -!3 = distinct !DISubprogram(name: "__main__global_stmts", scope: !1, file: !1, line: 1, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) -!4 = !DISubroutineType(types: !5) -!5 = !{null} -!6 = !DILocation(line: 9, column: 1, scope: !3) -!7 = distinct !DISubprogram(name: "main0", scope: !1, file: !1, line: 1, type: !4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) -!8 = !DILocation(line: 1, column: 1, scope: !7) -!9 = !DILocalVariable(name: "x", arg: 1, scope: !7, file: !1, line: 2, type: !10) -!10 = !DIBasicType(name: "integer", size: 32, encoding: DW_ATE_signed) -!11 = !DILocation(line: 2, scope: !7) -!12 = !DILocalVariable(name: "x2", arg: 2, scope: !7, file: !1, line: 3, type: !13) -!13 = !DIBasicType(name: "integer", size: 64, encoding: DW_ATE_signed) -!14 = !DILocation(line: 3, scope: !7) -!15 = !DILocalVariable(name: "y", arg: 3, scope: !7, file: !1, line: 4, type: !16) -!16 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float) -!17 = !DILocation(line: 4, scope: !7) -!18 = !DILocalVariable(name: "y2", arg: 4, scope: !7, file: !1, line: 5, type: !19) -!19 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float) -!20 = !DILocation(line: 5, scope: !7) -!21 = !DILocation(line: 6, column: 5, scope: !7) -!22 = distinct !DISubprogram(name: "main_program", scope: !1, file: !1, line: 1, type: !23, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) -!23 = !DISubroutineType(types: !24) -!24 = !{!10} -!25 = !DILocation(line: 1, column: 1, scope: !22) diff --git a/tests/reference/pass_print_list_tuple-print_02-09600eb.json b/tests/reference/pass_print_list_tuple-print_02-09600eb.json index 171e8ff3a4..bf60bbd5bb 100644 --- a/tests/reference/pass_print_list_tuple-print_02-09600eb.json +++ b/tests/reference/pass_print_list_tuple-print_02-09600eb.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "pass_print_list_tuple-print_02-09600eb.stdout", - "stdout_hash": "45287b2b8687c93c743646c0f46a1df04b98717114b36fe5ded301c3", + "stdout_hash": "41e70f047be117bcadd0d281fac364a8ec319b565a82a262d0cf6c45", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/pass_print_list_tuple-print_02-09600eb.stdout b/tests/reference/pass_print_list_tuple-print_02-09600eb.stdout index 0285cc6f12..7e0d4e8137 100644 --- a/tests/reference/pass_print_list_tuple-print_02-09600eb.stdout +++ b/tests/reference/pass_print_list_tuple-print_02-09600eb.stdout @@ -7220,7 +7220,9 @@ )] (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) (TupleConstant @@ -7231,13 +7233,17 @@ )] (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) )] (List (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) ) @@ -7250,7 +7256,9 @@ )] (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) (TupleConstant @@ -7261,13 +7269,17 @@ )] (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) )] (List (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) )] @@ -7275,7 +7287,9 @@ (List (Tuple [(Integer 4) - (String 1 (IntegerConstant 1 (Integer 4) Decimal) ExpressionLength DescriptorString)] + (Allocatable + (String 1 () DeferredLength DescriptorString) + )] ) ) ) diff --git a/tests/reference/run_dbg-test_assert_01-2f34744.json b/tests/reference/run_dbg-test_assert_01-2f34744.json index f8ac5ccbe9..570a13e706 100644 --- a/tests/reference/run_dbg-test_assert_01-2f34744.json +++ b/tests/reference/run_dbg-test_assert_01-2f34744.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "run_dbg-test_assert_01-2f34744.stderr", - "stderr_hash": "4811af471c73572b285e9ea01c8689abdd3cb32c717b3cd4876d2669", - "returncode": 1 + "stderr_hash": "00ddc89bd7b49589d524136cdf56c9b4d7661cab8637dc18c947809a", + "returncode": 109 } \ No newline at end of file diff --git a/tests/reference/run_dbg-test_assert_01-2f34744.stderr b/tests/reference/run_dbg-test_assert_01-2f34744.stderr index a7dc14d623..c4f4d77f69 100644 --- a/tests/reference/run_dbg-test_assert_01-2f34744.stderr +++ b/tests/reference/run_dbg-test_assert_01-2f34744.stderr @@ -1,7 +1,2 @@ - File "tests/runtime_errors/test_assert_01.py", line 1 - def test(): - File "tests/runtime_errors/test_assert_01.py", line 4 - test() - File "tests/runtime_errors/test_assert_01.py", line 2 - assert False -AssertionError +The following argument was not expected: --debug-with-line-column +Run with --help for more information. diff --git a/tests/reference/run_dbg-test_assert_03-bd7b7dd.json b/tests/reference/run_dbg-test_assert_03-bd7b7dd.json index f771107475..17522781dd 100644 --- a/tests/reference/run_dbg-test_assert_03-bd7b7dd.json +++ b/tests/reference/run_dbg-test_assert_03-bd7b7dd.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "run_dbg-test_assert_03-bd7b7dd.stderr", - "stderr_hash": "cae7dd955478787917e9dbb0bc1f63631317b13da1d892c3ebab9097", - "returncode": 1 + "stderr_hash": "00ddc89bd7b49589d524136cdf56c9b4d7661cab8637dc18c947809a", + "returncode": 109 } \ No newline at end of file diff --git a/tests/reference/run_dbg-test_assert_03-bd7b7dd.stderr b/tests/reference/run_dbg-test_assert_03-bd7b7dd.stderr index 65f2444ba9..c4f4d77f69 100644 --- a/tests/reference/run_dbg-test_assert_03-bd7b7dd.stderr +++ b/tests/reference/run_dbg-test_assert_03-bd7b7dd.stderr @@ -1,11 +1,2 @@ - File "tests/runtime_errors/test_assert_03.py", line 1 - def f(): - File "tests/runtime_errors/test_assert_03.py", line 10 - main() - File "tests/runtime_errors/test_assert_03.py", line 8 - f() - File "tests/runtime_errors/test_assert_03.py", line 2 - g() - File "tests/runtime_errors/test_assert_03.py", line 5 - assert False -AssertionError +The following argument was not expected: --debug-with-line-column +Run with --help for more information. diff --git a/tests/reference/run_dbg-test_quit_01-30889cc.json b/tests/reference/run_dbg-test_quit_01-30889cc.json index 37ce5d232a..befeaf9d82 100644 --- a/tests/reference/run_dbg-test_quit_01-30889cc.json +++ b/tests/reference/run_dbg-test_quit_01-30889cc.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "run_dbg-test_quit_01-30889cc.stderr", - "stderr_hash": "56a8b2a9b2ee213cbfab4c18870ed93ddbfaa37e421f171155d06d4f", - "returncode": 10 + "stderr_hash": "00ddc89bd7b49589d524136cdf56c9b4d7661cab8637dc18c947809a", + "returncode": 109 } \ No newline at end of file diff --git a/tests/reference/run_dbg-test_quit_01-30889cc.stderr b/tests/reference/run_dbg-test_quit_01-30889cc.stderr index 5fd4fe85c8..c4f4d77f69 100644 --- a/tests/reference/run_dbg-test_quit_01-30889cc.stderr +++ b/tests/reference/run_dbg-test_quit_01-30889cc.stderr @@ -1,7 +1,2 @@ - File "tests/runtime_errors/test_quit_01.py", line 1 - def test(): - File "tests/runtime_errors/test_quit_01.py", line 4 - test() - File "tests/runtime_errors/test_quit_01.py", line 2 - quit(10) -STOP 10 +The following argument was not expected: --debug-with-line-column +Run with --help for more information. diff --git a/tests/reference/run_dbg-test_raise_01-dfd86ca.json b/tests/reference/run_dbg-test_raise_01-dfd86ca.json index 2dbe004c7e..06e08e5af2 100644 --- a/tests/reference/run_dbg-test_raise_01-dfd86ca.json +++ b/tests/reference/run_dbg-test_raise_01-dfd86ca.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "run_dbg-test_raise_01-dfd86ca.stderr", - "stderr_hash": "76085f527077a81ba6457af8f982a497038168f555ab4027d0d6340e", - "returncode": 1 + "stderr_hash": "00ddc89bd7b49589d524136cdf56c9b4d7661cab8637dc18c947809a", + "returncode": 109 } \ No newline at end of file diff --git a/tests/reference/run_dbg-test_raise_01-dfd86ca.stderr b/tests/reference/run_dbg-test_raise_01-dfd86ca.stderr index 42bc707825..c4f4d77f69 100644 --- a/tests/reference/run_dbg-test_raise_01-dfd86ca.stderr +++ b/tests/reference/run_dbg-test_raise_01-dfd86ca.stderr @@ -1,7 +1,2 @@ - File "tests/runtime_errors/test_raise_01.py", line 1 - def test(): - File "tests/runtime_errors/test_raise_01.py", line 4 - test() - File "tests/runtime_errors/test_raise_01.py", line 2 - raise -ERROR STOP +The following argument was not expected: --debug-with-line-column +Run with --help for more information. diff --git a/tests/reference/wat-bool1-234bcd1.json b/tests/reference/wat-bool1-234bcd1.json index 4be1a3e7c1..8408a6a4e9 100644 --- a/tests/reference/wat-bool1-234bcd1.json +++ b/tests/reference/wat-bool1-234bcd1.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "wat-bool1-234bcd1.stdout", - "stdout_hash": "1ac138f5c0fd3b21a75e6bf4e0024d5f0df2f0a6b195defd472677c2", + "stdout_hash": "2e3f8393736b812efe0611846f07c5b2cfbfad0c465f990b706c2681", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/wat-bool1-234bcd1.stdout b/tests/reference/wat-bool1-234bcd1.stdout index b50b0ccd6a..5593fd2504 100644 --- a/tests/reference/wat-bool1-234bcd1.stdout +++ b/tests/reference/wat-bool1-234bcd1.stdout @@ -9,11 +9,13 @@ (import "wasi_snapshot_preview1" "fd_write" (func (;1;) (type 1))) (global $0 (mut i32) (i32.const 0)) (global $1 (mut i32) (i32.const 0)) - (global $2 (mut i64) (i64.const 0)) - (global $3 (mut f32) (f32.const 0.000000)) - (global $4 (mut f32) (f32.const 0.000000)) - (global $5 (mut f64) (f64.const 0.000000)) - (global $6 (mut f64) (f64.const 0.000000)) + (global $2 (mut i32) (i32.const 0)) + (global $3 (mut i64) (i64.const 0)) + (global $4 (mut i64) (i64.const 0)) + (global $5 (mut f32) (f32.const 0.000000)) + (global $6 (mut f32) (f32.const 0.000000)) + (global $7 (mut f64) (f64.const 0.000000)) + (global $8 (mut f64) (f64.const 0.000000)) (func $2 (type 2) (param) (result) (local) call 3 diff --git a/tests/reference/wat-expr14-5e0cb96.json b/tests/reference/wat-expr14-5e0cb96.json index 09741a198d..0e14e135e3 100644 --- a/tests/reference/wat-expr14-5e0cb96.json +++ b/tests/reference/wat-expr14-5e0cb96.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "wat-expr14-5e0cb96.stdout", - "stdout_hash": "f8ff7eb9eb4bc533fc4d36c58a0378df6dfbf135313962dbf379d69a", + "stdout_hash": "6eedbad94110199fa8729d7142c869546f6cafc17267b2a6c055157e", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/wat-expr14-5e0cb96.stdout b/tests/reference/wat-expr14-5e0cb96.stdout index 60c9b0a760..d77fbbcda6 100644 --- a/tests/reference/wat-expr14-5e0cb96.stdout +++ b/tests/reference/wat-expr14-5e0cb96.stdout @@ -6,11 +6,13 @@ (import "wasi_snapshot_preview1" "fd_write" (func (;1;) (type 1))) (global $0 (mut i32) (i32.const 0)) (global $1 (mut i32) (i32.const 0)) - (global $2 (mut i64) (i64.const 0)) - (global $3 (mut f32) (f32.const 0.000000)) - (global $4 (mut f32) (f32.const 0.000000)) - (global $5 (mut f64) (f64.const 0.000000)) - (global $6 (mut f64) (f64.const 0.000000)) + (global $2 (mut i32) (i32.const 0)) + (global $3 (mut i64) (i64.const 0)) + (global $4 (mut i64) (i64.const 0)) + (global $5 (mut f32) (f32.const 0.000000)) + (global $6 (mut f32) (f32.const 0.000000)) + (global $7 (mut f64) (f64.const 0.000000)) + (global $8 (mut f64) (f64.const 0.000000)) (func $2 (type 2) (param) (result) (local) i32.const 0 diff --git a/tests/reference/wat-expr2-8b17723.json b/tests/reference/wat-expr2-8b17723.json index ad73a311e7..29c8d8ed57 100644 --- a/tests/reference/wat-expr2-8b17723.json +++ b/tests/reference/wat-expr2-8b17723.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "wat-expr2-8b17723.stdout", - "stdout_hash": "f8ff7eb9eb4bc533fc4d36c58a0378df6dfbf135313962dbf379d69a", + "stdout_hash": "6eedbad94110199fa8729d7142c869546f6cafc17267b2a6c055157e", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/wat-expr2-8b17723.stdout b/tests/reference/wat-expr2-8b17723.stdout index 60c9b0a760..d77fbbcda6 100644 --- a/tests/reference/wat-expr2-8b17723.stdout +++ b/tests/reference/wat-expr2-8b17723.stdout @@ -6,11 +6,13 @@ (import "wasi_snapshot_preview1" "fd_write" (func (;1;) (type 1))) (global $0 (mut i32) (i32.const 0)) (global $1 (mut i32) (i32.const 0)) - (global $2 (mut i64) (i64.const 0)) - (global $3 (mut f32) (f32.const 0.000000)) - (global $4 (mut f32) (f32.const 0.000000)) - (global $5 (mut f64) (f64.const 0.000000)) - (global $6 (mut f64) (f64.const 0.000000)) + (global $2 (mut i32) (i32.const 0)) + (global $3 (mut i64) (i64.const 0)) + (global $4 (mut i64) (i64.const 0)) + (global $5 (mut f32) (f32.const 0.000000)) + (global $6 (mut f32) (f32.const 0.000000)) + (global $7 (mut f64) (f64.const 0.000000)) + (global $8 (mut f64) (f64.const 0.000000)) (func $2 (type 2) (param) (result) (local) i32.const 0 diff --git a/tests/reference/wat-print_str-385e953.json b/tests/reference/wat-print_str-385e953.json index de1714455f..f9be8cc565 100644 --- a/tests/reference/wat-print_str-385e953.json +++ b/tests/reference/wat-print_str-385e953.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "wat-print_str-385e953.stdout", - "stdout_hash": "8e9a0f7a017cdd451f10e9b8686d3a9ba00c1c4088fbd01cfa2df1cc", + "stdout_hash": "2bb8bff1b8678e1dca9acefc6c48f2ea921e0f754d2f2f116d152c48", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/wat-print_str-385e953.stdout b/tests/reference/wat-print_str-385e953.stdout index 9db655a5ed..f07e666890 100644 --- a/tests/reference/wat-print_str-385e953.stdout +++ b/tests/reference/wat-print_str-385e953.stdout @@ -9,11 +9,13 @@ (import "wasi_snapshot_preview1" "fd_write" (func (;1;) (type 1))) (global $0 (mut i32) (i32.const 0)) (global $1 (mut i32) (i32.const 0)) - (global $2 (mut i64) (i64.const 0)) - (global $3 (mut f32) (f32.const 0.000000)) - (global $4 (mut f32) (f32.const 0.000000)) - (global $5 (mut f64) (f64.const 0.000000)) - (global $6 (mut f64) (f64.const 0.000000)) + (global $2 (mut i32) (i32.const 0)) + (global $3 (mut i64) (i64.const 0)) + (global $4 (mut i64) (i64.const 0)) + (global $5 (mut f32) (f32.const 0.000000)) + (global $6 (mut f32) (f32.const 0.000000)) + (global $7 (mut f64) (f64.const 0.000000)) + (global $8 (mut f64) (f64.const 0.000000)) (func $2 (type 2) (param) (result) (local) call 3 From 9eb455094ab744080a4d9ec53ccdb1a946619684 Mon Sep 17 00:00:00 2001 From: swamishiju Date: Sun, 18 Jan 2026 01:14:36 +0530 Subject: [PATCH 3/3] updated tests --- integration_tests/CMakeLists.txt | 16 +-- libasr | 2 +- src/lpython/semantics/python_ast_to_asr.cpp | 9 +- src/lpython/semantics/python_intrinsic_eval.h | 43 +++--- tests/reference/asr-expr_07-7742668.json | 2 +- tests/reference/asr-expr_07-7742668.stdout | 36 +----- tests/reference/asr-structs_09-f3ffe08.json | 13 -- tests/reference/asr-structs_09-f3ffe08.stderr | 23 ---- tests/reference/llvm-bool1-af4376b.json | 2 +- tests/reference/llvm-bool1-af4376b.stdout | 122 +++++++++++------- tests/reference/llvm-expr_01-54467c1.json | 2 +- tests/reference/llvm-expr_01-54467c1.stdout | 9 +- .../llvm-func_inline_01-2d4583a.json | 2 +- .../llvm-func_inline_01-2d4583a.stdout | 26 ++-- tests/reference/llvm-print_04-443a8d8.json | 2 +- tests/reference/llvm-print_04-443a8d8.stdout | 118 ++++++++++------- .../llvm-test_issue_518-cdb641a.json | 2 +- .../llvm-test_issue_518-cdb641a.stdout | 9 +- .../runtime-test_dict14-421fe53.json | 2 +- .../runtime-test_dict14-421fe53.stderr | 3 +- .../runtime-test_dict15-6f3af0d.json | 2 +- .../runtime-test_dict15-6f3af0d.stderr | 3 +- .../runtime-test_list_01-3ee9b3e.json | 2 +- .../runtime-test_list_01-3ee9b3e.stderr | 3 +- .../runtime-test_list_02-5f7db5f.json | 2 +- .../runtime-test_list_02-5f7db5f.stderr | 3 +- .../runtime-test_list_index-0483808.json | 2 +- .../runtime-test_list_index-0483808.stderr | 3 +- .../runtime-test_list_index2-1249233.json | 2 +- .../runtime-test_list_index2-1249233.stderr | 3 +- .../runtime-test_list_index3-647a94a.json | 2 +- .../runtime-test_list_index3-647a94a.stderr | 3 +- .../runtime-test_list_index4-c31dfdb.json | 2 +- .../runtime-test_list_index4-c31dfdb.stderr | 3 +- tests/tests.toml | 6 +- 35 files changed, 253 insertions(+), 231 deletions(-) delete mode 100644 tests/reference/asr-structs_09-f3ffe08.json delete mode 100644 tests/reference/asr-structs_09-f3ffe08.stderr diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index e81feb9db2..8b29358e20 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -465,9 +465,9 @@ RUN(NAME print_04 LABELS cpython llvm llvm_jit c) RUN(NAME print_06 LABELS cpython llvm llvm_jit) # renable c RUN(NAME print_05 LABELS cpython llvm llvm_jit c wasm wasm_x64) RUN(NAME print_float LABELS cpython llvm llvm_jit c wasm wasm_x64) -# RUN(NAME print_list_tuple_01 LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync +RUN(NAME print_list_tuple_01 LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync # RUN(NAME print_list_tuple_02 LABELS cpython llvm llvm_jit c NOFAST) -# RUN(NAME print_list_tuple_03 LABELS cpython llvm llvm_jit c NOFAST) +RUN(NAME print_list_tuple_03 LABELS cpython llvm llvm_jit c NOFAST) RUN(NAME test_list_item_mixed_print LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync # RUN(NAME test_intrinsic_function_mixed_print LABELS cpython llvm llvm_jit NOFAST) # post sync @@ -562,11 +562,11 @@ RUN(NAME test_list_concat LABELS cpython llvm llvm_jit c NOFAST) # RUN(NAME test_list_reserve LABELS cpython llvm llvm_jit) # post sync # RUN(NAME test_const_list LABELS cpython llvm llvm_jit) # post sync # RUN(NAME test_const_access LABELS cpython llvm llvm_jit) # post sync -# RUN(NAME test_tuple_01 LABELS cpython llvm llvm_jit) # renable c # post sync -# RUN(NAME test_tuple_02 LABELS cpython llvm llvm_jit c NOFAST) -# RUN(NAME test_tuple_03 LABELS cpython llvm llvm_jit) # renable c # post sync -# RUN(NAME test_tuple_04 LABELS cpython llvm llvm_jit) # renable c # post sync -# RUN(NAME test_tuple_concat LABELS cpython llvm llvm_jit) # post sync +RUN(NAME test_tuple_01 LABELS cpython llvm llvm_jit) # renable c # post sync +RUN(NAME test_tuple_02 LABELS cpython llvm llvm_jit NOFAST) # renable c +RUN(NAME test_tuple_03 LABELS cpython llvm llvm_jit) # renable c # post sync +RUN(NAME test_tuple_04 LABELS cpython llvm llvm_jit) # renable c # post sync +RUN(NAME test_tuple_concat LABELS cpython llvm llvm_jit) # post sync # RUN(NAME test_tuple_nested LABELS cpython llvm llvm_jit) # post sync # RUN(NAME test_const_dict LABELS cpython llvm llvm_jit) # post sync # RUN(NAME test_params LABELS cpython llvm llvm_jit NOFAST) @@ -671,7 +671,7 @@ RUN(NAME test_c_interop_01 LABELS cpython llvm llvm_jit c) # RUN(NAME bindpy_06 LABELS cpython llvm_py EXTRA_ARGS --enable-cpython NOFAST COPY_TO_BIN bindpy_06_module.py REQ_PY_VER 3.10) # RUN(NAME test_generics_01 LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync RUN(NAME test_cmath LABELS cpython llvm llvm_jit c NOFAST) -RUN(NAME test_complex_01 LABELS cpython llvm llvm_jit c wasm wasm_x64) +RUN(NAME test_complex_01 LABELS cpython llvm llvm_jit c wasm) # renable wasm_x64 RUN(NAME test_complex_02 LABELS cpython llvm llvm_jit c) RUN(NAME test_ConstantEllipsis LABLES cpython llvm llvm_jit c) RUN(NAME test_max_min LABELS cpython llvm llvm_jit c) diff --git a/libasr b/libasr index e84b66d34e..83d865ba88 160000 --- a/libasr +++ b/libasr @@ -1 +1 @@ -Subproject commit e84b66d34ecc4a8b85477cbc3899ecb667ed7d4a +Subproject commit 83d865ba88b843a2c4e07b86c0854302b1c188d3 diff --git a/src/lpython/semantics/python_ast_to_asr.cpp b/src/lpython/semantics/python_ast_to_asr.cpp index 2ce695f68b..33b939f49f 100644 --- a/src/lpython/semantics/python_ast_to_asr.cpp +++ b/src/lpython/semantics/python_ast_to_asr.cpp @@ -3518,7 +3518,14 @@ class CommonVisitor : public AST::BaseVisitor { this->visit_expr(*x.m_elts[i]); ASR::expr_t *expr = ASRUtils::EXPR(tmp); elements.push_back(al, expr); - tuple_type_vec.push_back(al, ASRUtils::expr_type(expr)); + ASR::ttype_t *type = ASRUtils::expr_type(expr); + + if (ASRUtils::is_character(*type) && !ASRUtils::is_allocatable(type)) + type = ASRUtils::TYPE(ASR::make_Allocatable_t(al, x.base.base.loc, + ASRUtils::TYPE(ASR::make_String_t(al, x.base.base.loc, 1, nullptr, + ASR::string_length_kindType::DeferredLength, + ASR::string_physical_typeType::DescriptorString)))); + tuple_type_vec.push_back(al, type); } ASR::ttype_t *tuple_type = ASRUtils::TYPE(ASR::make_Tuple_t(al, x.base.base.loc, tuple_type_vec.p, tuple_type_vec.n)); diff --git a/src/lpython/semantics/python_intrinsic_eval.h b/src/lpython/semantics/python_intrinsic_eval.h index 28527a22d2..dd090dcc6f 100644 --- a/src/lpython/semantics/python_intrinsic_eval.h +++ b/src/lpython/semantics/python_intrinsic_eval.h @@ -318,7 +318,6 @@ struct IntrinsicNodeHandler { loc); } ASR::expr_t *arg = nullptr; - ASR::expr_t *res_value = nullptr; ASR::ttype_t *arg_type = nullptr; if (args.size() > 0) { arg = args[0].m_value; @@ -345,43 +344,43 @@ struct IntrinsicNodeHandler { sm << ival; std::string value_str = sm.str(); sm.clear(); - ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_Allocatable_t(al, loc, - ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr, - ASR::string_length_kindType::DeferredLength, - ASR::string_physical_typeType::DescriptorString)))); - res_value = ASR::down_cast(ASR::make_StringConstant_t(al, - loc, s2c(al, value_str), res_type)); + ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, + ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, + value_str.size(), ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4)))), + ASR::string_length_kindType::ExpressionLength, + ASR::string_physical_typeType::DescriptorString)); + return ASR::make_StringConstant_t(al, loc, s2c(al, value_str), res_type); } return ASR::make_Cast_t(al, loc, arg, ASR::cast_kindType::RealToString, - str_type, res_value); + str_type, nullptr); } else if (ASRUtils::is_integer(*arg_type)) { if (ASRUtils::expr_value(arg) != nullptr) { int64_t number = ASR::down_cast( ASRUtils::expr_value(arg))->m_n; std::string value_str = std::to_string(number); - ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_Allocatable_t(al, loc, - ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr, - ASR::string_length_kindType::DeferredLength, - ASR::string_physical_typeType::DescriptorString)))); - res_value = ASR::down_cast(ASR::make_StringConstant_t(al, - loc, s2c(al, value_str), res_type)); + ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, + ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, + value_str.size(), ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4)))), + ASR::string_length_kindType::ExpressionLength, + ASR::string_physical_typeType::DescriptorString)); + return ASR::make_StringConstant_t(al, loc, s2c(al, value_str), res_type); } return ASR::make_Cast_t(al, loc, arg, ASR::cast_kindType::IntegerToString, - str_type, res_value); + str_type, nullptr); } else if (ASRUtils::is_logical(*arg_type)) { if(ASRUtils::expr_value(arg) != nullptr) { bool bool_number = ASR::down_cast( ASRUtils::expr_value(arg))->m_value; std::string value_str = (bool_number)? "True" : "False"; - ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_Allocatable_t(al, loc, - ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr, - ASR::string_length_kindType::DeferredLength, - ASR::string_physical_typeType::DescriptorString)))); - res_value = ASR::down_cast(ASR::make_StringConstant_t(al, - loc, s2c(al, value_str), res_type)); + ASR::ttype_t* res_type = ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, + ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, + value_str.size(), ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 4)))), + ASR::string_length_kindType::ExpressionLength, + ASR::string_physical_typeType::DescriptorString)); + return ASR::make_StringConstant_t(al, loc, s2c(al, value_str), res_type); } return ASR::make_Cast_t(al, loc, arg, ASR::cast_kindType::LogicalToString, - str_type, res_value); + str_type, nullptr); } else if (ASRUtils::is_character(*arg_type)) { return (ASR::asr_t *)arg; diff --git a/tests/reference/asr-expr_07-7742668.json b/tests/reference/asr-expr_07-7742668.json index 9904c4b3cf..c4adbdc7f5 100644 --- a/tests/reference/asr-expr_07-7742668.json +++ b/tests/reference/asr-expr_07-7742668.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-expr_07-7742668.stdout", - "stdout_hash": "0d3d169b0a1f448e4ad89216fee756394c1c6940c1ca69cfce55db7e", + "stdout_hash": "e3b92590c8ed8ad023b08d698688be23b7ac8b33c35d5d8b8c1cf47f", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-expr_07-7742668.stdout b/tests/reference/asr-expr_07-7742668.stdout index abeaf9dfcd..ce94f0c1a3 100644 --- a/tests/reference/asr-expr_07-7742668.stdout +++ b/tests/reference/asr-expr_07-7742668.stdout @@ -109,21 +109,9 @@ (Print (StringFormat () - [(Cast - (LogicalConstant - .true. - (Logical 4) - ) - LogicalToString - (Allocatable - (String 1 () DeferredLength DescriptorString) - ) - (StringConstant - "True" - (Allocatable - (String 1 () DeferredLength DescriptorString) - ) - ) + [(StringConstant + "True" + (String 1 (IntegerConstant 4 (Integer 4) Decimal) ExpressionLength DescriptorString) )] FormatPythonFormat (Allocatable @@ -184,21 +172,9 @@ ) (Assert (StringCompare - (Cast - (LogicalConstant - .true. - (Logical 4) - ) - LogicalToString - (Allocatable - (String 1 () DeferredLength DescriptorString) - ) - (StringConstant - "True" - (Allocatable - (String 1 () DeferredLength DescriptorString) - ) - ) + (StringConstant + "True" + (String 1 (IntegerConstant 4 (Integer 4) Decimal) ExpressionLength DescriptorString) ) Eq (StringConstant diff --git a/tests/reference/asr-structs_09-f3ffe08.json b/tests/reference/asr-structs_09-f3ffe08.json deleted file mode 100644 index 8f306ed10c..0000000000 --- a/tests/reference/asr-structs_09-f3ffe08.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "basename": "asr-structs_09-f3ffe08", - "cmd": "lpython --show-asr --no-color {infile} -o {outfile}", - "infile": "tests/errors/structs_09.py", - "infile_hash": "06fb179f0c0c41124ffc960676a9f32cfe112ab4e39c6f6a7cb2a6e3", - "outfile": null, - "outfile_hash": null, - "stdout": null, - "stdout_hash": null, - "stderr": "asr-structs_09-f3ffe08.stderr", - "stderr_hash": "b37b8fa37881df2189147ce1d10d155f0d770374a0ebd9a9cbf312a8", - "returncode": 1 -} \ No newline at end of file diff --git a/tests/reference/asr-structs_09-f3ffe08.stderr b/tests/reference/asr-structs_09-f3ffe08.stderr deleted file mode 100644 index a8c7fdc37d..0000000000 --- a/tests/reference/asr-structs_09-f3ffe08.stderr +++ /dev/null @@ -1,23 +0,0 @@ -Internal Compiler Error: Unhandled exception -Traceback (most recent call last): - File "$DIR/lpython.cpp", line 2142 - File "$DIR/lpython.cpp", line 216 - File "$DIR/semantics/python_ast_to_asr.cpp", line 9188 - File "$DIR/semantics/python_ast_to_asr.cpp", line 9120 - File "$DIR/semantics/python_ast_to_asr.cpp", line 5204 - File "$DIR/python_ast.h", line 1909 - File "$DIR/python_ast.h", line 1776 - File "$DIR/semantics/python_ast_to_asr.cpp", line 5394 - File "$DIR/semantics/python_ast_to_asr.cpp", line 5370 - File "$DIR/semantics/python_ast_to_asr.cpp", line 5158 - File "$DIR/python_ast.h", line 1909 - File "$DIR/python_ast.h", line 1782 - File "$DIR/semantics/python_ast_to_asr.cpp", line 5466 - File "$DIR/semantics/python_ast_to_asr.cpp", line 2898 - File "$DIR/python_ast.h", line 1936 - File "$DIR/python_ast.h", line 1825 - File "$DIR/semantics/python_ast_to_asr.cpp", line 8505 - File "$DIR/semantics/python_ast_to_asr.cpp", line 8245 - File "$DIR/libasr/src/libasr/containers.h", line 164 - LCOMPILERS_ASSERT(pos < n); -AssertFailed: pos < n diff --git a/tests/reference/llvm-bool1-af4376b.json b/tests/reference/llvm-bool1-af4376b.json index f933df1ddb..1698394743 100644 --- a/tests/reference/llvm-bool1-af4376b.json +++ b/tests/reference/llvm-bool1-af4376b.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "llvm-bool1-af4376b.stdout", - "stdout_hash": "4f5e9e47913b161e75dbb0d660944f50aaa93833807e5a8a27266421", + "stdout_hash": "54c9741d96dda09561f0e1dcf888a87bafd62f48b55921b648873f06", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/llvm-bool1-af4376b.stdout b/tests/reference/llvm-bool1-af4376b.stdout index 87b2ef9511..2b92eb51ec 100644 --- a/tests/reference/llvm-bool1-af4376b.stdout +++ b/tests/reference/llvm-bool1-af4376b.stdout @@ -47,59 +47,87 @@ define void @__module___main___test_bool() { %9 = load i64, i64* %8, align 4 %10 = trunc i64 %9 to i32 call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i8* %7, i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0), i32 1) + %11 = icmp eq i8* %2, null + br i1 %11, label %free_done, label %free_nonnull + +free_nonnull: ; preds = %.entry call void @_lfortran_free(i8* %2) - %11 = alloca i64, align 8 - %12 = alloca i1, align 1 - store i1 false, i1* %12, align 1 - %13 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @serialization_info.1, i32 0, i32 0), i64* %11, i32 0, i32 0, i1* %12) - %14 = load i64, i64* %11, align 4 + br label %free_done + +free_done: ; preds = %free_nonnull, %.entry + %12 = alloca i64, align 8 + %13 = alloca i1, align 1 + store i1 false, i1* %13, align 1 + %14 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @serialization_info.1, i32 0, i32 0), i64* %12, i32 0, i32 0, i1* %13) + %15 = load i64, i64* %12, align 4 %stringFormat_desc1 = alloca %string_descriptor, align 8 - %15 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 0 - store i8* %13, i8** %15, align 8 - %16 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 1 - store i64 %14, i64* %16, align 4 - %17 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 0 - %18 = load i8*, i8** %17, align 8 - %19 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 1 - %20 = load i64, i64* %19, align 4 - %21 = trunc i64 %20 to i32 - call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @3, i32 0, i32 0), i8* %18, i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0), i32 1) - call void @_lfortran_free(i8* %13) + %16 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 0 + store i8* %14, i8** %16, align 8 + %17 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 1 + store i64 %15, i64* %17, align 4 + %18 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 0 + %19 = load i8*, i8** %18, align 8 + %20 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 1 + %21 = load i64, i64* %20, align 4 + %22 = trunc i64 %21 to i32 + call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @3, i32 0, i32 0), i8* %19, i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0), i32 1) + %23 = icmp eq i8* %14, null + br i1 %23, label %free_done3, label %free_nonnull2 + +free_nonnull2: ; preds = %free_done + call void @_lfortran_free(i8* %14) + br label %free_done3 + +free_done3: ; preds = %free_nonnull2, %free_done store i1 true, i1* %b, align 1 - %22 = alloca i64, align 8 - %23 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @serialization_info.2, i32 0, i32 0), i64* %22, i32 0, i32 0, i1* %b) - %24 = load i64, i64* %22, align 4 - %stringFormat_desc2 = alloca %string_descriptor, align 8 - %25 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc2, i32 0, i32 0 - store i8* %23, i8** %25, align 8 - %26 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc2, i32 0, i32 1 - store i64 %24, i64* %26, align 4 - %27 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc2, i32 0, i32 0 - %28 = load i8*, i8** %27, align 8 - %29 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc2, i32 0, i32 1 - %30 = load i64, i64* %29, align 4 - %31 = trunc i64 %30 to i32 - call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @5, i32 0, i32 0), i8* %28, i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @4, i32 0, i32 0), i32 1) - call void @_lfortran_free(i8* %23) + %24 = alloca i64, align 8 + %25 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @serialization_info.2, i32 0, i32 0), i64* %24, i32 0, i32 0, i1* %b) + %26 = load i64, i64* %24, align 4 + %stringFormat_desc4 = alloca %string_descriptor, align 8 + %27 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc4, i32 0, i32 0 + store i8* %25, i8** %27, align 8 + %28 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc4, i32 0, i32 1 + store i64 %26, i64* %28, align 4 + %29 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc4, i32 0, i32 0 + %30 = load i8*, i8** %29, align 8 + %31 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc4, i32 0, i32 1 + %32 = load i64, i64* %31, align 4 + %33 = trunc i64 %32 to i32 + call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @5, i32 0, i32 0), i8* %30, i32 %33, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @4, i32 0, i32 0), i32 1) + %34 = icmp eq i8* %25, null + br i1 %34, label %free_done6, label %free_nonnull5 + +free_nonnull5: ; preds = %free_done3 + call void @_lfortran_free(i8* %25) + br label %free_done6 + +free_done6: ; preds = %free_nonnull5, %free_done3 store i1 false, i1* %b, align 1 - %32 = alloca i64, align 8 - %33 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @serialization_info.3, i32 0, i32 0), i64* %32, i32 0, i32 0, i1* %b) - %34 = load i64, i64* %32, align 4 - %stringFormat_desc3 = alloca %string_descriptor, align 8 - %35 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc3, i32 0, i32 0 - store i8* %33, i8** %35, align 8 - %36 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc3, i32 0, i32 1 - store i64 %34, i64* %36, align 4 - %37 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc3, i32 0, i32 0 - %38 = load i8*, i8** %37, align 8 - %39 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc3, i32 0, i32 1 - %40 = load i64, i64* %39, align 4 - %41 = trunc i64 %40 to i32 - call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @7, i32 0, i32 0), i8* %38, i32 %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @6, i32 0, i32 0), i32 1) - call void @_lfortran_free(i8* %33) + %35 = alloca i64, align 8 + %36 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @serialization_info.3, i32 0, i32 0), i64* %35, i32 0, i32 0, i1* %b) + %37 = load i64, i64* %35, align 4 + %stringFormat_desc7 = alloca %string_descriptor, align 8 + %38 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc7, i32 0, i32 0 + store i8* %36, i8** %38, align 8 + %39 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc7, i32 0, i32 1 + store i64 %37, i64* %39, align 4 + %40 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc7, i32 0, i32 0 + %41 = load i8*, i8** %40, align 8 + %42 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc7, i32 0, i32 1 + %43 = load i64, i64* %42, align 4 + %44 = trunc i64 %43 to i32 + call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @7, i32 0, i32 0), i8* %41, i32 %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @6, i32 0, i32 0), i32 1) + %45 = icmp eq i8* %36, null + br i1 %45, label %free_done9, label %free_nonnull8 + +free_nonnull8: ; preds = %free_done6 + call void @_lfortran_free(i8* %36) + br label %free_done9 + +free_done9: ; preds = %free_nonnull8, %free_done6 br label %return -return: ; preds = %.entry +return: ; preds = %free_done9 br label %FINALIZE_SYMTABLE_test_bool FINALIZE_SYMTABLE_test_bool: ; preds = %return diff --git a/tests/reference/llvm-expr_01-54467c1.json b/tests/reference/llvm-expr_01-54467c1.json index 4f25a972f7..9056697882 100644 --- a/tests/reference/llvm-expr_01-54467c1.json +++ b/tests/reference/llvm-expr_01-54467c1.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "llvm-expr_01-54467c1.stdout", - "stdout_hash": "ebd056da5b17b5948f274361494023fbc8f6901f94b8cd4e9c9fda54", + "stdout_hash": "fa2a6f649ea413a35ca8b1865c69fab904b935485b77c04a1829ba0a", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/llvm-expr_01-54467c1.stdout b/tests/reference/llvm-expr_01-54467c1.stdout index 7cb73ff076..2e43c8e9a0 100644 --- a/tests/reference/llvm-expr_01-54467c1.stdout +++ b/tests/reference/llvm-expr_01-54467c1.stdout @@ -40,10 +40,17 @@ define void @__module___main___main0() { %8 = load i64, i64* %7, align 4 %9 = trunc i64 %8 to i32 call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i8* %6, i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0), i32 1) + %10 = icmp eq i8* %1, null + br i1 %10, label %free_done, label %free_nonnull + +free_nonnull: ; preds = %.entry call void @_lfortran_free(i8* %1) + br label %free_done + +free_done: ; preds = %free_nonnull, %.entry br label %return -return: ; preds = %.entry +return: ; preds = %free_done br label %FINALIZE_SYMTABLE_main0 FINALIZE_SYMTABLE_main0: ; preds = %return diff --git a/tests/reference/llvm-func_inline_01-2d4583a.json b/tests/reference/llvm-func_inline_01-2d4583a.json index 61f683adf1..69782bf1fe 100644 --- a/tests/reference/llvm-func_inline_01-2d4583a.json +++ b/tests/reference/llvm-func_inline_01-2d4583a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "llvm-func_inline_01-2d4583a.stdout", - "stdout_hash": "46430e9433d6bf4ec78b924c4a58204916e658b2b3721c5baf9b8e35", + "stdout_hash": "2d7a423d1cffd4a167a798b1c54f73aecddf141f3a4197ecd271fb63", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/llvm-func_inline_01-2d4583a.stdout b/tests/reference/llvm-func_inline_01-2d4583a.stdout index c480acd514..cf5d4cd404 100644 --- a/tests/reference/llvm-func_inline_01-2d4583a.stdout +++ b/tests/reference/llvm-func_inline_01-2d4583a.stdout @@ -22,7 +22,6 @@ FINALIZE_SYMTABLE___main__global_stmts: ; preds = %return define i64 @__module___main___fib(i64* %n) { .entry: - %call_arg_value1 = alloca i64, align 8 %call_arg_value = alloca i64, align 8 %_lpython_return_variable = alloca i64, align 8 %0 = load i64, i64* %n, align 4 @@ -47,16 +46,16 @@ ifcont: ; preds = %else, %unreachable_ %5 = call i64 @__module___main___fib(i64* %call_arg_value) %6 = load i64, i64* %n, align 4 %7 = sub i64 %6, 2 - store i64 %7, i64* %call_arg_value1, align 4 - %8 = call i64 @__module___main___fib(i64* %call_arg_value1) + store i64 %7, i64* %call_arg_value, align 4 + %8 = call i64 @__module___main___fib(i64* %call_arg_value) %9 = add i64 %5, %8 store i64 %9, i64* %_lpython_return_variable, align 4 br label %return -unreachable_after_return2: ; No predecessors! +unreachable_after_return1: ; No predecessors! br label %return -return: ; preds = %unreachable_after_return2, %ifcont, %then +return: ; preds = %unreachable_after_return1, %ifcont, %then br label %FINALIZE_SYMTABLE_fib FINALIZE_SYMTABLE_fib: ; preds = %return @@ -85,15 +84,22 @@ define void @__module___main____xx_lcompilers_changed_main_xx() { %9 = load i64, i64* %8, align 4 %10 = trunc i64 %9 to i32 call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i8* %7, i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0), i32 1) + %11 = icmp eq i8* %2, null + br i1 %11, label %free_done, label %free_nonnull + +free_nonnull: ; preds = %.entry call void @_lfortran_free(i8* %2) - %11 = load i64, i64* %ans, align 4 - %12 = icmp eq i64 %11, 102334155 - br i1 %12, label %then, label %else + br label %free_done -then: ; preds = %.entry +free_done: ; preds = %free_nonnull, %.entry + %12 = load i64, i64* %ans, align 4 + %13 = icmp eq i64 %12, 102334155 + br i1 %13, label %then, label %else + +then: ; preds = %free_done br label %ifcont -else: ; preds = %.entry +else: ; preds = %free_done call void (i8*, ...) @_lcompilers_print_error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @2, i32 0, i32 0)) call void @exit(i32 1) br label %ifcont diff --git a/tests/reference/llvm-print_04-443a8d8.json b/tests/reference/llvm-print_04-443a8d8.json index 03a20489d5..22a7543039 100644 --- a/tests/reference/llvm-print_04-443a8d8.json +++ b/tests/reference/llvm-print_04-443a8d8.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "llvm-print_04-443a8d8.stdout", - "stdout_hash": "90d292a24e2d8532a4f06b5c03e04593f66b36025ea9668b3f931114", + "stdout_hash": "3372748ce557c15d904ff98cfb2c5c6219c15d26e5a67b48c1c90ab1", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/llvm-print_04-443a8d8.stdout b/tests/reference/llvm-print_04-443a8d8.stdout index f0c76d1a84..68cdf07050 100644 --- a/tests/reference/llvm-print_04-443a8d8.stdout +++ b/tests/reference/llvm-print_04-443a8d8.stdout @@ -36,55 +36,83 @@ define void @__module___main_____main__global_stmts() { %8 = load i64, i64* %7, align 4 %9 = trunc i64 %8 to i32 call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @1, i32 0, i32 0), i8* %6, i32 %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @0, i32 0, i32 0), i32 1) + %10 = icmp eq i8* %1, null + br i1 %10, label %free_done, label %free_nonnull + +free_nonnull: ; preds = %.entry call void @_lfortran_free(i8* %1) - %10 = alloca i64, align 8 - %11 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info.1, i32 0, i32 0), i64* %10, i32 0, i32 0, i32* @__module___main___x) - %12 = load i64, i64* %10, align 4 + br label %free_done + +free_done: ; preds = %free_nonnull, %.entry + %11 = alloca i64, align 8 + %12 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info.1, i32 0, i32 0), i64* %11, i32 0, i32 0, i32* @__module___main___x) + %13 = load i64, i64* %11, align 4 %stringFormat_desc1 = alloca %string_descriptor, align 8 - %13 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 0 - store i8* %11, i8** %13, align 8 - %14 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 1 - store i64 %12, i64* %14, align 4 - %15 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 0 - %16 = load i8*, i8** %15, align 8 - %17 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 1 - %18 = load i64, i64* %17, align 4 - %19 = trunc i64 %18 to i32 - call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @3, i32 0, i32 0), i8* %16, i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0), i32 1) - call void @_lfortran_free(i8* %11) - %20 = alloca i64, align 8 - %21 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info.2, i32 0, i32 0), i64* %20, i32 0, i32 0, i16* @__module___main___y) - %22 = load i64, i64* %20, align 4 - %stringFormat_desc2 = alloca %string_descriptor, align 8 - %23 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc2, i32 0, i32 0 - store i8* %21, i8** %23, align 8 - %24 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc2, i32 0, i32 1 - store i64 %22, i64* %24, align 4 - %25 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc2, i32 0, i32 0 - %26 = load i8*, i8** %25, align 8 - %27 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc2, i32 0, i32 1 - %28 = load i64, i64* %27, align 4 - %29 = trunc i64 %28 to i32 - call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @5, i32 0, i32 0), i8* %26, i32 %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @4, i32 0, i32 0), i32 1) - call void @_lfortran_free(i8* %21) - %30 = alloca i64, align 8 - %31 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info.3, i32 0, i32 0), i64* %30, i32 0, i32 0, i8* @__module___main___z) - %32 = load i64, i64* %30, align 4 - %stringFormat_desc3 = alloca %string_descriptor, align 8 - %33 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc3, i32 0, i32 0 - store i8* %31, i8** %33, align 8 - %34 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc3, i32 0, i32 1 - store i64 %32, i64* %34, align 4 - %35 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc3, i32 0, i32 0 - %36 = load i8*, i8** %35, align 8 - %37 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc3, i32 0, i32 1 - %38 = load i64, i64* %37, align 4 - %39 = trunc i64 %38 to i32 - call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @7, i32 0, i32 0), i8* %36, i32 %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @6, i32 0, i32 0), i32 1) - call void @_lfortran_free(i8* %31) + %14 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 0 + store i8* %12, i8** %14, align 8 + %15 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 1 + store i64 %13, i64* %15, align 4 + %16 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 0 + %17 = load i8*, i8** %16, align 8 + %18 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc1, i32 0, i32 1 + %19 = load i64, i64* %18, align 4 + %20 = trunc i64 %19 to i32 + call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @3, i32 0, i32 0), i8* %17, i32 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @2, i32 0, i32 0), i32 1) + %21 = icmp eq i8* %12, null + br i1 %21, label %free_done3, label %free_nonnull2 + +free_nonnull2: ; preds = %free_done + call void @_lfortran_free(i8* %12) + br label %free_done3 + +free_done3: ; preds = %free_nonnull2, %free_done + %22 = alloca i64, align 8 + %23 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info.2, i32 0, i32 0), i64* %22, i32 0, i32 0, i16* @__module___main___y) + %24 = load i64, i64* %22, align 4 + %stringFormat_desc4 = alloca %string_descriptor, align 8 + %25 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc4, i32 0, i32 0 + store i8* %23, i8** %25, align 8 + %26 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc4, i32 0, i32 1 + store i64 %24, i64* %26, align 4 + %27 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc4, i32 0, i32 0 + %28 = load i8*, i8** %27, align 8 + %29 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc4, i32 0, i32 1 + %30 = load i64, i64* %29, align 4 + %31 = trunc i64 %30 to i32 + call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @5, i32 0, i32 0), i8* %28, i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @4, i32 0, i32 0), i32 1) + %32 = icmp eq i8* %23, null + br i1 %32, label %free_done6, label %free_nonnull5 + +free_nonnull5: ; preds = %free_done3 + call void @_lfortran_free(i8* %23) + br label %free_done6 + +free_done6: ; preds = %free_nonnull5, %free_done3 + %33 = alloca i64, align 8 + %34 = call i8* (i8*, i64, i8*, i64*, i32, i32, ...) @_lcompilers_string_format_fortran(i8* null, i64 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @serialization_info.3, i32 0, i32 0), i64* %33, i32 0, i32 0, i8* @__module___main___z) + %35 = load i64, i64* %33, align 4 + %stringFormat_desc7 = alloca %string_descriptor, align 8 + %36 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc7, i32 0, i32 0 + store i8* %34, i8** %36, align 8 + %37 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc7, i32 0, i32 1 + store i64 %35, i64* %37, align 4 + %38 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc7, i32 0, i32 0 + %39 = load i8*, i8** %38, align 8 + %40 = getelementptr %string_descriptor, %string_descriptor* %stringFormat_desc7, i32 0, i32 1 + %41 = load i64, i64* %40, align 4 + %42 = trunc i64 %41 to i32 + call void @_lfortran_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @7, i32 0, i32 0), i8* %39, i32 %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @6, i32 0, i32 0), i32 1) + %43 = icmp eq i8* %34, null + br i1 %43, label %free_done9, label %free_nonnull8 + +free_nonnull8: ; preds = %free_done6 + call void @_lfortran_free(i8* %34) + br label %free_done9 + +free_done9: ; preds = %free_nonnull8, %free_done6 br label %return -return: ; preds = %.entry +return: ; preds = %free_done9 br label %FINALIZE_SYMTABLE___main__global_stmts FINALIZE_SYMTABLE___main__global_stmts: ; preds = %return diff --git a/tests/reference/llvm-test_issue_518-cdb641a.json b/tests/reference/llvm-test_issue_518-cdb641a.json index f80a2640bb..fd57d31d46 100644 --- a/tests/reference/llvm-test_issue_518-cdb641a.json +++ b/tests/reference/llvm-test_issue_518-cdb641a.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "llvm-test_issue_518-cdb641a.stdout", - "stdout_hash": "85ff823581b50af2a7174ab24f8ae40ee7eac67a616724a034e4d4a9", + "stdout_hash": "0ec194f023f976a3330377671c7174a9965bb523cdcd1a5a1510a41b", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/llvm-test_issue_518-cdb641a.stdout b/tests/reference/llvm-test_issue_518-cdb641a.stdout index 7d17fe955c..7031ec4bed 100644 --- a/tests/reference/llvm-test_issue_518-cdb641a.stdout +++ b/tests/reference/llvm-test_issue_518-cdb641a.stdout @@ -19,7 +19,6 @@ FINALIZE_SYMTABLE___main__global_stmts: ; preds = %return define i64 @__module___main___fib(i64* %n) { .entry: - %call_arg_value1 = alloca i64, align 8 %call_arg_value = alloca i64, align 8 %_lpython_return_variable = alloca i64, align 8 %0 = load i64, i64* %n, align 4 @@ -41,16 +40,16 @@ else: ; preds = %.entry %5 = call i64 @__module___main___fib(i64* %call_arg_value) %6 = load i64, i64* %n, align 4 %7 = sub i64 %6, 2 - store i64 %7, i64* %call_arg_value1, align 4 - %8 = call i64 @__module___main___fib(i64* %call_arg_value1) + store i64 %7, i64* %call_arg_value, align 4 + %8 = call i64 @__module___main___fib(i64* %call_arg_value) %9 = add i64 %5, %8 store i64 %9, i64* %_lpython_return_variable, align 4 br label %return -unreachable_after_return2: ; No predecessors! +unreachable_after_return1: ; No predecessors! br label %ifcont -ifcont: ; preds = %unreachable_after_return2, %unreachable_after_return +ifcont: ; preds = %unreachable_after_return1, %unreachable_after_return br label %return return: ; preds = %ifcont, %else, %then diff --git a/tests/reference/runtime-test_dict14-421fe53.json b/tests/reference/runtime-test_dict14-421fe53.json index ae6a837f77..8aebc686bb 100644 --- a/tests/reference/runtime-test_dict14-421fe53.json +++ b/tests/reference/runtime-test_dict14-421fe53.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "runtime-test_dict14-421fe53.stderr", - "stderr_hash": "cb46ef04db0862506d688ebe8830a50afaaead9b0d29b0c007dd149a", + "stderr_hash": "c785d28fd05e473e7742aeaabf28e1e1864649bbff4c155f481fbed0", "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/runtime-test_dict14-421fe53.stderr b/tests/reference/runtime-test_dict14-421fe53.stderr index e8c90e4e1d..2d1d478fd7 100644 --- a/tests/reference/runtime-test_dict14-421fe53.stderr +++ b/tests/reference/runtime-test_dict14-421fe53.stderr @@ -1 +1,2 @@ -KeyError: The dict does not contain the specified key +runtime error: KeyError: The dict does not contain the specified key + diff --git a/tests/reference/runtime-test_dict15-6f3af0d.json b/tests/reference/runtime-test_dict15-6f3af0d.json index 5bf5c80a4b..b24d0dced3 100644 --- a/tests/reference/runtime-test_dict15-6f3af0d.json +++ b/tests/reference/runtime-test_dict15-6f3af0d.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "runtime-test_dict15-6f3af0d.stderr", - "stderr_hash": "cb46ef04db0862506d688ebe8830a50afaaead9b0d29b0c007dd149a", + "stderr_hash": "c785d28fd05e473e7742aeaabf28e1e1864649bbff4c155f481fbed0", "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/runtime-test_dict15-6f3af0d.stderr b/tests/reference/runtime-test_dict15-6f3af0d.stderr index e8c90e4e1d..2d1d478fd7 100644 --- a/tests/reference/runtime-test_dict15-6f3af0d.stderr +++ b/tests/reference/runtime-test_dict15-6f3af0d.stderr @@ -1 +1,2 @@ -KeyError: The dict does not contain the specified key +runtime error: KeyError: The dict does not contain the specified key + diff --git a/tests/reference/runtime-test_list_01-3ee9b3e.json b/tests/reference/runtime-test_list_01-3ee9b3e.json index 0c845eb4e6..5e197c98ff 100644 --- a/tests/reference/runtime-test_list_01-3ee9b3e.json +++ b/tests/reference/runtime-test_list_01-3ee9b3e.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "runtime-test_list_01-3ee9b3e.stderr", - "stderr_hash": "c9cbdc4df1e7fbe0a6e73db7ac7809f71102fb524c8aa86139271006", + "stderr_hash": "96899c9ee5b80fbd6679be329941320a224b3e10f47cf5927c6fb36f", "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/runtime-test_list_01-3ee9b3e.stderr b/tests/reference/runtime-test_list_01-3ee9b3e.stderr index 86d697f5c2..2f6378afbc 100644 --- a/tests/reference/runtime-test_list_01-3ee9b3e.stderr +++ b/tests/reference/runtime-test_list_01-3ee9b3e.stderr @@ -1 +1,2 @@ -ValueError: The list does not contain the element: 4 +runtime error: ValueError: The list does not contain the element: 4 + diff --git a/tests/reference/runtime-test_list_02-5f7db5f.json b/tests/reference/runtime-test_list_02-5f7db5f.json index c4afb880c4..0b1bb5e7e8 100644 --- a/tests/reference/runtime-test_list_02-5f7db5f.json +++ b/tests/reference/runtime-test_list_02-5f7db5f.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "runtime-test_list_02-5f7db5f.stderr", - "stderr_hash": "f45ba86e610eeb2cc11fc176120e56d153a896f486e9b04d94fa3de1", + "stderr_hash": "0cbff339e66c0c092f05f5b0a979d214e0656e0e9084bf47a7ca304e", "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/runtime-test_list_02-5f7db5f.stderr b/tests/reference/runtime-test_list_02-5f7db5f.stderr index 4f2d5a50c5..baf28d88e1 100644 --- a/tests/reference/runtime-test_list_02-5f7db5f.stderr +++ b/tests/reference/runtime-test_list_02-5f7db5f.stderr @@ -1 +1,2 @@ -IndexError: List index is out of range. Index range is (0, 2), but the given index is 3 +runtime error: IndexError: List index is out of range. Index range is (0, 2), but the given index is 3 + diff --git a/tests/reference/runtime-test_list_index-0483808.json b/tests/reference/runtime-test_list_index-0483808.json index 36ec2cbe9d..b288b4825c 100644 --- a/tests/reference/runtime-test_list_index-0483808.json +++ b/tests/reference/runtime-test_list_index-0483808.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "runtime-test_list_index-0483808.stderr", - "stderr_hash": "dd3d49b5f2f97ed8f1d27cd73ebca7a8740483660dd4ae702e2048b2", + "stderr_hash": "d40342cc08f5ea8aa145e2afb27dc8eb667cf59eb10c0cd31fab0aa1", "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/runtime-test_list_index-0483808.stderr b/tests/reference/runtime-test_list_index-0483808.stderr index 93fd195103..4b92f087d5 100644 --- a/tests/reference/runtime-test_list_index-0483808.stderr +++ b/tests/reference/runtime-test_list_index-0483808.stderr @@ -1 +1,2 @@ -ValueError: The list does not contain the element: 0 +runtime error: ValueError: The list does not contain the element: 0 + diff --git a/tests/reference/runtime-test_list_index2-1249233.json b/tests/reference/runtime-test_list_index2-1249233.json index f1e4344ce2..fa1a1e3d83 100644 --- a/tests/reference/runtime-test_list_index2-1249233.json +++ b/tests/reference/runtime-test_list_index2-1249233.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "runtime-test_list_index2-1249233.stderr", - "stderr_hash": "fc647b30c89710c23d7efec0fe4390894c725680b5d8c4b4c939a5bf", + "stderr_hash": "99bb5bd555fab6c51e67bdcaf2a8b708423dfb3369fd6ba3a0a815d5", "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/runtime-test_list_index2-1249233.stderr b/tests/reference/runtime-test_list_index2-1249233.stderr index 68bd909af9..dc25af3470 100644 --- a/tests/reference/runtime-test_list_index2-1249233.stderr +++ b/tests/reference/runtime-test_list_index2-1249233.stderr @@ -1 +1,2 @@ -ValueError: The list does not contain the element: 1 +runtime error: ValueError: The list does not contain the element: 1 + diff --git a/tests/reference/runtime-test_list_index3-647a94a.json b/tests/reference/runtime-test_list_index3-647a94a.json index 6a0d2c606b..de1d5045d8 100644 --- a/tests/reference/runtime-test_list_index3-647a94a.json +++ b/tests/reference/runtime-test_list_index3-647a94a.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "runtime-test_list_index3-647a94a.stderr", - "stderr_hash": "fc647b30c89710c23d7efec0fe4390894c725680b5d8c4b4c939a5bf", + "stderr_hash": "99bb5bd555fab6c51e67bdcaf2a8b708423dfb3369fd6ba3a0a815d5", "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/runtime-test_list_index3-647a94a.stderr b/tests/reference/runtime-test_list_index3-647a94a.stderr index 68bd909af9..dc25af3470 100644 --- a/tests/reference/runtime-test_list_index3-647a94a.stderr +++ b/tests/reference/runtime-test_list_index3-647a94a.stderr @@ -1 +1,2 @@ -ValueError: The list does not contain the element: 1 +runtime error: ValueError: The list does not contain the element: 1 + diff --git a/tests/reference/runtime-test_list_index4-c31dfdb.json b/tests/reference/runtime-test_list_index4-c31dfdb.json index 237d1a5f2e..1367b0b167 100644 --- a/tests/reference/runtime-test_list_index4-c31dfdb.json +++ b/tests/reference/runtime-test_list_index4-c31dfdb.json @@ -8,6 +8,6 @@ "stdout": null, "stdout_hash": null, "stderr": "runtime-test_list_index4-c31dfdb.stderr", - "stderr_hash": "3e3eee1ba7f96c1edaeed1c7b93f54b397dbe3b08d20c9b720c291a5", + "stderr_hash": "fd9cc5268c5acba314c94205251347e3c8cc24bf6d489eadcd7fa30f", "returncode": 1 } \ No newline at end of file diff --git a/tests/reference/runtime-test_list_index4-c31dfdb.stderr b/tests/reference/runtime-test_list_index4-c31dfdb.stderr index 6adc6bd250..7dc89a61a6 100644 --- a/tests/reference/runtime-test_list_index4-c31dfdb.stderr +++ b/tests/reference/runtime-test_list_index4-c31dfdb.stderr @@ -1 +1,2 @@ -ValueError: The list does not contain the element: 2 +runtime error: ValueError: The list does not contain the element: 2 + diff --git a/tests/tests.toml b/tests/tests.toml index d023d7befe..15453b503a 100644 --- a/tests/tests.toml +++ b/tests/tests.toml @@ -775,9 +775,9 @@ asr = true filename = "errors/structs_08.py" asr = true -[[test]] -filename = "errors/structs_09.py" -asr = true +# [[test]] +# filename = "errors/structs_09.py" +# asr = true [[test]] filename = "errors/structs_10.py"