Skip to content

Commit 490191c

Browse files
committed
print fixes
1 parent d289bf8 commit 490191c

File tree

4 files changed

+25
-19
lines changed

4 files changed

+25
-19
lines changed

integration_tests/CMakeLists.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -459,10 +459,10 @@ RUN(NAME exit_02b FAIL LABELS cpython llvm llvm_jit c wasm wasm_x86 wasm_x
459459
RUN(NAME exit_02c FAIL LABELS cpython llvm llvm_jit c)
460460

461461
# Test all four backends
462-
# RUN(NAME print_01 LABELS cpython llvm llvm_jit wasm) # renable c, wasm not yet supports sep and end keywords # post sync
462+
RUN(NAME print_01 LABELS cpython llvm llvm_jit wasm) # renable c, wasm not yet supports sep and end keywords
463463
RUN(NAME print_03 LABELS x86 c wasm wasm_x86 wasm_x64) # simple test case specifically for x86, wasm_x86 and wasm_x64
464464
RUN(NAME print_04 LABELS cpython llvm llvm_jit c)
465-
# RUN(NAME print_06 LABELS cpython llvm llvm_jit) # renable c # post sync
465+
RUN(NAME print_06 LABELS cpython llvm llvm_jit) # renable c
466466
RUN(NAME print_05 LABELS cpython llvm llvm_jit c wasm wasm_x64)
467467
RUN(NAME print_float LABELS cpython llvm llvm_jit c wasm wasm_x64)
468468
RUN(NAME print_list_tuple_01 LABELS cpython llvm llvm_jit NOFAST) # renable c
@@ -510,7 +510,7 @@ RUN(NAME expr_02u LABELS cpython llvm llvm_jit c NOFAST)
510510

511511
RUN(NAME list_01 LABELS cpython llvm llvm_jit)
512512

513-
# RUN(NAME loop_01 LABELS cpython llvm llvm_jit) # renable c # post sync
513+
RUN(NAME loop_01 LABELS cpython llvm llvm_jit) # renable c
514514
RUN(NAME loop_02 LABELS cpython llvm llvm_jit c wasm wasm_x86 wasm_x64)
515515
RUN(NAME loop_03 LABELS cpython llvm llvm_jit c wasm wasm_x64)
516516
RUN(NAME loop_04 LABELS cpython llvm llvm_jit c)
@@ -552,7 +552,7 @@ RUN(NAME test_list_index LABELS cpython llvm llvm_jit)
552552
RUN(NAME test_list_index2 LABELS cpython llvm llvm_jit)
553553
# RUN(NAME test_list_repeat LABELS cpython llvm llvm_jit c NOFAST)
554554
# RUN(NAME test_list_repeat2 LABELS cpython llvm llvm_jit c NOFAST)
555-
# RUN(NAME test_list_reverse LABELS cpython llvm llvm_jit) # post sync
555+
RUN(NAME test_list_reverse LABELS cpython llvm llvm_jit)
556556
# RUN(NAME test_list_pop LABELS cpython llvm llvm_jit NOFAST) # TODO: Remove NOFAST from here.
557557
# RUN(NAME test_list_pop2 LABELS cpython llvm llvm_jit NOFAST) # TODO: Remove NOFAST from here.
558558
RUN(NAME test_list_pop3 LABELS cpython llvm llvm_jit)
@@ -583,13 +583,13 @@ RUN(NAME test_dict_10 LABELS cpython llvm llvm_jit) # renable c
583583
RUN(NAME test_dict_11 LABELS cpython llvm llvm_jit c)
584584
RUN(NAME test_dict_12 LABELS cpython llvm llvm_jit) # renable c
585585
# RUN(NAME test_dict_13 LABELS cpython llvm llvm_jit c)
586-
# RUN(NAME test_dict_bool LABELS cpython llvm llvm_jit) # post sync
586+
RUN(NAME test_dict_bool LABELS cpython llvm llvm_jit)
587587
# RUN(NAME test_dict_increment LABELS cpython llvm llvm_jit)
588588
# RUN(NAME test_dict_keys_values LABELS cpython llvm llvm_jit)
589589
# RUN(NAME test_dict_nested1 LABELS cpython llvm llvm_jit)
590590
# RUN(NAME test_dict_clear LABELS cpython llvm)
591591
RUN(NAME test_set_len LABELS cpython llvm llvm_jit)
592-
# RUN(NAME test_set_add LABELS cpython llvm llvm_jit) # post sync
592+
RUN(NAME test_set_add LABELS cpython llvm llvm_jit)
593593
# RUN(NAME test_set_remove LABELS cpython llvm llvm_jit)
594594
# RUN(NAME test_set_discard LABELS cpython llvm llvm_jit)
595595
# RUN(NAME test_set_from_list LABELS cpython llvm llvm_jit)
@@ -599,9 +599,9 @@ RUN(NAME test_global_set LABELS cpython llvm llvm_jit)
599599
RUN(NAME test_for_loop LABELS cpython llvm llvm_jit c)
600600
RUN(NAME modules_01 LABELS cpython llvm llvm_jit c wasm wasm_x86 wasm_x64)
601601
RUN(NAME modules_02 LABELS cpython llvm llvm_jit c wasm wasm_x86 wasm_x64)
602-
# RUN(NAME test_import_01 LABELS cpython llvm llvm_jit) # renable c # post sync
602+
RUN(NAME test_import_01 LABELS cpython llvm llvm_jit) # renable c
603603
RUN(NAME test_import_02 LABELS cpython llvm llvm_jit c)
604-
# RUN(NAME test_import_03 LABELS cpython llvm llvm_jit) # renable c # post sync
604+
RUN(NAME test_import_03 LABELS cpython llvm llvm_jit) # renable c
605605
RUN(NAME test_import_04 LABELS cpython llvm llvm_jit c)
606606
RUN(NAME test_import_05 LABELS cpython llvm llvm_jit c wasm wasm_x86 wasm_x64)
607607
RUN(NAME test_import_06 LABELS cpython llvm llvm_jit)
@@ -628,8 +628,8 @@ RUN(NAME elemental_12 LABELS cpython llvm llvm_jit c NOFAST)
628628
RUN(NAME elemental_13 LABELS cpython llvm llvm_jit c NOFAST)
629629
RUN(NAME test_random LABELS cpython llvm llvm_jit NOFAST)
630630
RUN(NAME test_random_02 LABELS cpython llvm llvm_jit NOFAST)
631-
# RUN(NAME test_os LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync
632-
# RUN(NAME test_builtin LABELS cpython llvm llvm_jit) # renable c # post sync
631+
# RUN(NAME test_os LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync
632+
# RUN(NAME test_builtin LABELS cpython llvm llvm_jit) # renable c # post sync
633633
RUN(NAME test_builtin_abs LABELS cpython llvm llvm_jit c)
634634
# RUN(NAME test_builtin_bool LABELS cpython llvm llvm_jit c)
635635
# RUN(NAME test_builtin_pow LABELS cpython llvm llvm_jit c EXTRA_ARGS --no-warnings)
@@ -669,7 +669,7 @@ RUN(NAME test_c_interop_03 LABELS cpython llvm c
669669
# RUN(NAME bindpy_04 LABELS cpython c_py EXTRA_ARGS --link-numpy NOFAST COPY_TO_BIN bindpy_04_module.py)
670670
# RUN(NAME bindpy_05 LABELS llvm_py c_py EXTRA_ARGS --enable-cpython COPY_TO_BIN bindpy_05_module.py REQ_PY_VER 3.10)
671671
# 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)
672-
# RUN(NAME test_generics_01 LABELS cpython llvm llvm_jit NOFAST) # renable c # post sync
672+
RUN(NAME test_generics_01 LABELS cpython llvm llvm_jit NOFAST) # renable c
673673
RUN(NAME test_cmath LABELS cpython llvm llvm_jit c NOFAST)
674674
RUN(NAME test_complex_01 LABELS cpython llvm llvm_jit c wasm wasm_x64)
675675
RUN(NAME test_complex_02 LABELS cpython llvm llvm_jit c)
@@ -774,7 +774,7 @@ RUN(NAME union_04 IMPORT_PATH ..
774774
# RUN(NAME test_str_to_int LABELS cpython llvm llvm_jit c)
775775
# RUN(NAME test_platform LABELS cpython llvm llvm_jit) # renable c
776776
RUN(NAME test_vars_01 LABELS cpython llvm llvm_jit)
777-
# RUN(NAME test_version LABELS cpython llvm llvm_jit) # post sync
777+
RUN(NAME test_version LABELS cpython llvm llvm_jit)
778778
RUN(NAME logical_binop1 LABELS cpython llvm llvm_jit)
779779
# RUN(NAME test_logical_compare LABELS cpython llvm llvm_jit) # TODO: Add C backend after fixing issue #2708
780780
# RUN(NAME test_logical_assignment LABELS cpython llvm llvm_jit) # TODO: Add C backend after fixing issue #2708
@@ -794,18 +794,18 @@ RUN(NAME test_bit_length LABELS cpython) # renable c, FIXME: This test fails
794794
# RUN(NAME test_pkg_lnn_02 LABELS cpython llvm llvm_jit NOFAST)
795795
# RUN(NAME test_pkg_lpconvexhull LABELS cpython llvm llvm_jit c NOFAST)
796796

797-
# RUN(NAME generics_01 LABELS cpython llvm llvm_jit) # renable c # post sync
797+
RUN(NAME generics_01 LABELS cpython llvm llvm_jit) # renable c
798798
# RUN(NAME generics_02 LABELS cpython llvm llvm_jit c)
799799
RUN(NAME generics_array_01 LABELS cpython llvm llvm_jit c)
800800
RUN(NAME generics_array_02 LABELS cpython llvm llvm_jit c)
801801
RUN(NAME generics_array_03 LABELS cpython llvm llvm_jit c)
802-
# RUN(NAME generics_list_01 LABELS cpython llvm llvm_jit) # renable c # post sync
802+
RUN(NAME generics_list_01 LABELS cpython llvm llvm_jit) # renable c
803803
RUN(NAME test_statistics_01 LABELS cpython llvm llvm_jit NOFAST)
804804
# RUN(NAME test_statistics_02 LABELS cpython llvm llvm_jit NOFAST REQ_PY_VER 3.10)
805805
# RUN(NAME test_attributes LABELS cpython llvm llvm_jit)
806806
# RUN(NAME test_str_attributes LABELS cpython llvm llvm_jit c)
807807
# RUN(NAME kwargs_01 LABELS cpython llvm llvm_jit NOFAST) # renable c
808-
# RUN(NAME def_func_01 LABELS cpython llvm llvm_jit) # renable c # post sync
808+
RUN(NAME def_func_01 LABELS cpython llvm llvm_jit) # renable c
809809

810810
RUN(NAME func_inline_01 LABELS llvm llvm_jit c wasm)
811811
RUN(NAME func_inline_02 LABELS cpython llvm llvm_jit c)
@@ -838,7 +838,7 @@ RUN(NAME callback_03 LABELS cpython llvm llvm_jit c)
838838

839839
RUN(NAME lambda_01 LABELS cpython llvm llvm_jit)
840840

841-
# RUN(NAME c_mangling LABELS cpython llvm llvm_jit) # renable c # post sync
841+
RUN(NAME c_mangling LABELS cpython llvm llvm_jit) # renable c
842842
# RUN(NAME class_01 LABELS cpython llvm llvm_jit)
843843
# RUN(NAME class_02 LABELS cpython llvm llvm_jit)
844844
# RUN(NAME class_03 LABELS cpython llvm llvm_jit)

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,7 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
890890
type = ASRUtils::make_Array_t_util(al, loc, type, dims.p, dims.size(), abi, is_argument);
891891
} else if (var_annotation == "str") {
892892
type = ASRUtils::TYPE(ASR::make_String_t(al, loc, 1,
893-
ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, -2,
893+
ASRUtils::EXPR(ASR::make_IntegerConstant_t(al, loc, 0,
894894
ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 8)))),
895895
false, false, ASR::string_physical_typeType::PointerString));
896896
type = ASRUtils::make_Array_t_util(al, loc, type, dims.p, dims.size(), abi, is_argument);
@@ -2652,6 +2652,11 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
26522652
v_variable->n_dependencies = variable_dependencies_vec.size();
26532653
v_variable->m_symbolic_value = init_expr;
26542654
v_variable->m_value = value;
2655+
2656+
if ( value && ASR::is_a<ASR::StringConstant_t>(*value) && ASR::is_a<ASR::String_t>(*type) ) {
2657+
ASR::String_t* str_type = ASR::down_cast<ASR::String_t>(v_variable->m_type);
2658+
((ASR::IntegerConstant_t *)str_type->m_len)->m_n = std::string(ASR::down_cast<ASR::StringConstant_t>(value)->m_s).size();
2659+
}
26552660
}
26562661

26572662
bool is_runtime_expression = !ASRUtils::is_value_constant(value);

src/lpython/semantics/python_intrinsic_eval.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <libasr/string_utils.h>
77
#include <lpython/utils.h>
88
#include <lpython/semantics/semantic_exception.h>
9+
#include <libasr/asr_utils.h>
910

1011
namespace LCompilers::LPython {
1112

@@ -324,7 +325,7 @@ struct IntrinsicNodeHandler {
324325
arg_type = ASRUtils::expr_type(arg);
325326
}
326327
ASR::expr_t* a_len = ASRUtils::EXPR(ASR::make_IntegerConstant_t(al,
327-
loc, -2, ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 8))));
328+
loc, 0, ASRUtils::TYPE(ASR::make_Integer_t(al, loc, 8))));
328329
ASR::ttype_t *str_type = ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, a_len, false, false,
329330
ASR::string_physical_typeType::PointerString));
330331
if (!arg) {

0 commit comments

Comments
 (0)