Skip to content

Improvement: Support string repeat with a non-constant integer #2652

Closed
@kmr-srbh

Description

@kmr-srbh
from lpython import i32

my_string: str = "#"
n: i32 = 5

print(my_string * n)
(base) saurabh-kumar@Awadh:~/Projects/System/lpython$ ./src/bin/lpython ./examples/example.py
Internal Compiler Error: Unhandled exception
Traceback (most recent call last):
.
.
.
  File "/home/saurabh-kumar/Projects/System/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 3462, in LCompilers::LPython::CommonVisitor<LCompilers::LPython::BodyVisitor>::visit_BinOp(LCompilers::LPython::AST::BinOp_t const&)
    make_BinOp_helper(left, right, op, x.base.base.loc);
  File "/home/saurabh-kumar/Projects/System/lpython/src/lpython/semantics/python_ast_to_asr.cpp", line 2055, in LCompilers::LPython::CommonVisitor<LCompilers::LPython::BodyVisitor>::make_BinOp_helper(LCompilers::ASR::expr_t*, LCompilers::ASR::expr_t*, LCompilers::ASR::binopType, LCompilers::Location const&)
    right_int = ASR::down_cast<ASR::IntegerConstant_t>(
AssertFailed: f != nullptr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions