@@ -1079,15 +1079,17 @@ class ASRToLLVMVisitor : public ASR::BaseVisitor<ASRToLLVMVisitor>
1079
1079
// throw CodeGenError("Only string(a:b) for a,b variables for now.", x.base.base.loc);
1080
1080
// Use the "right" index for now
1081
1081
this ->visit_expr_wrapper (x.m_args [0 ].m_right , true );
1082
- llvm::Value *idx = tmp;
1082
+ llvm::Value *idx2 = tmp;
1083
+ this ->visit_expr_wrapper (x.m_args [0 ].m_left , true );
1084
+ llvm::Value *idx1 = tmp;
1083
1085
// idx = builder->CreateSub(idx, llvm::ConstantInt::get(context, llvm::APInt(32, 1)));
1084
1086
// std::vector<llvm::Value*> idx_vec = {llvm::ConstantInt::get(context, llvm::APInt(32, 0)), idx};
1085
1087
// std::vector<llvm::Value*> idx_vec = {idx};
1086
1088
llvm::Value *str = CreateLoad (array);
1087
1089
// llvm::Value *p = CreateGEP(str, idx_vec);
1088
1090
// TODO: Currently the string starts at the right location, but goes to the end of the original string.
1089
1091
// We have to allocate a new string, copy it and add null termination.
1090
- llvm::Value *p = lfortran_str_copy (str, idx, idx );
1092
+ llvm::Value *p = lfortran_str_copy (str, idx1, idx2 );
1091
1093
1092
1094
tmp = builder->CreateAlloca (character_type, nullptr );
1093
1095
builder->CreateStore (p, tmp);
0 commit comments