Skip to content

Commit 15f6eec

Browse files
committed
Add cast node as required
1 parent c02aa33 commit 15f6eec

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/lpython/semantics/python_intrinsic_eval.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,11 @@ struct IntrinsicNodeHandler {
457457
value = ASR::down_cast<ASR::expr_t>(
458458
ASR::make_StringConstant_t(al, loc, s2c(al, svalue), str_type));
459459
}
460+
int kind = ASRUtils::extract_kind_from_ttype_t(type);
461+
if (kind != 4) {
462+
ASR::ttype_t* dest_type = ASRUtils::TYPE(ASR::make_Integer_t(al,loc, 4));
463+
arg = ASRUtils::EXPR(ASR::make_Cast_t(al, loc, arg, ASR::cast_kindType::IntegerToInteger, dest_type, nullptr));
464+
}
460465
return ASR::make_StringChr_t(al, loc, arg, str_type, value);
461466
} else {
462467
throw SemanticError("'" + ASRUtils::type_to_str_python(type) + "' object cannot be interpreted as an integer",

0 commit comments

Comments
 (0)