Skip to content

Conversation

BobTheBuidler
Copy link
Contributor

No description provided.

if is_str_rprimitive(node_type) or isinstance(x, StrExpr):
# NOTE: why does mypyc think our fake StrExprs are not str rprimitives?
var_str = builder.accept(x)
elif (folded := constant_fold_expr(builder, x)) is not None:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foldable non-string values can be easily converted to str

var_str = builder.primitive_op(str_op, [builder.accept(x)], line)
elif format_op == FormatOp.INT:
if is_int_rprimitive(node_type) or is_short_int_rprimitive(node_type):
if isinstance(folded := constant_fold_expr(builder, x), int):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the expr can fold as an int we can convert it to str at build time

@BobTheBuidler
Copy link
Contributor Author

These tests should start working once #19982 is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant