Skip to content

Commit 7c5cd83

Browse files
committed
String item partial fix
1 parent 4554be6 commit 7c5cd83

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/lpython/semantics/python_ast_to_asr.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4265,7 +4265,23 @@ class CommonVisitor : public AST::BaseVisitor<StructType> {
42654265
if (ASRUtils::is_character(*type)) {
42664266
index = index_add_one(loc, index);
42674267
ai.m_right = index;
4268-
tmp = ASR::make_StringItem_t(al, loc, value, index, type, nullptr);
4268+
value = ASRUtils::EXPR(ASR::make_StringPhysicalCast_t(al, loc, value,
4269+
ASR::string_physical_typeType::DescriptorString,
4270+
ASR::string_physical_typeType::PointerString,
4271+
ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr,
4272+
ASR::string_length_kindType::DeferredLength,
4273+
ASR::string_physical_typeType::PointerString)), nullptr));
4274+
tmp = ASR::make_StringItem_t(al, loc, value, index,
4275+
ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr,
4276+
ASR::string_length_kindType::DeferredLength,
4277+
ASR::string_physical_typeType::PointerString)), nullptr);
4278+
4279+
if (ASR::down_cast<ASR::String_t>(ASRUtils::type_get_past_allocatable(ASR::down_cast<ASR::StringItem_t>(ASRUtils::EXPR(tmp))->m_type))->m_physical_type == ASR::string_physical_typeType::PointerString)
4280+
tmp = ASR::make_StringPhysicalCast_t(al, loc, ASRUtils::EXPR(tmp), ASR::string_physical_typeType::PointerString,
4281+
ASR::string_physical_typeType::DescriptorString,
4282+
ASRUtils::TYPE(ASR::make_String_t(al, loc, 1, nullptr,
4283+
ASR::string_length_kindType::DeferredLength,
4284+
ASR::string_physical_typeType::DescriptorString)), nullptr);
42694285
return false;
42704286
}
42714287
}

0 commit comments

Comments
 (0)