Skip to content

Commit 8a68800

Browse files
Update specialize.py
1 parent c5ebd11 commit 8a68800

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mypyc/irbuild/specialize.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -716,13 +716,13 @@ def translate_fstring(builder: IRBuilder, expr: CallExpr, callee: RefExpr) -> Va
716716

717717
# NOTE: not sure where I should put these helpers
718718
def is_literal_str(expr: Expression) -> bool:
719-
return isinstance(expr, StrExpr) or isinstance(expr, RefExpr) and expr.is_final
719+
return isinstance(expr, StrExpr) or isinstance(expr, RefExpr) and isinstance(expr.node, Var) and expr.node.final_value is not None
720720

721721
def get_literal_str(expr: Expression) -> str | None:
722722
if isinstance(expr, StrExpr):
723723
return expr.value
724-
elif isinstance(expr, RefExpr) and expr.is_final:
725-
return expr.final_value
724+
elif isinstance(expr, RefExpr) and isinstance(expr.node, Var) and expr.node.is_final:
725+
return str(expr.final_value)
726726
return None
727727

728728
while is_literal_str(exprs[i]) and is_literal_str(exprs[i + 1]):

0 commit comments

Comments
 (0)