Skip to content

Commit ade311d

Browse files
Update specialize.py
1 parent ab27873 commit ade311d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

mypyc/irbuild/specialize.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,15 +780,13 @@ def translate_fstring(builder: IRBuilder, expr: CallExpr, callee: RefExpr) -> Va
780780
exprs.append(item.args[0])
781781

782782
def get_literal_str(expr: Expression) -> str | None:
783-
if isinstance(expr, StrExpr):
784-
return expr.value
785-
return None
783+
return expr.value if isinstance(expr, StrExpr) else None
786784

787785
for i in range(len(exprs) - 1):
788786
while (
789787
len(exprs) >= i + 2
790-
and (first := get_literal_str(exprs[i])) is not None
791-
and (second := get_literal_str(exprs[i + 1])) is not None
788+
and (first := constant_fold_expr(builder, exprs[i])) is not None
789+
and (second := constant_fold_expr(builder, exprs[i + 1])) is not None
792790
):
793791
exprs = [*exprs[:i], StrExpr(first + second), *exprs[i + 2 :]]
794792
format_ops = [*format_ops[:i], FormatOp.STR, *format_ops[i + 2 :]]

0 commit comments

Comments
 (0)