Skip to content

Commit 70fa984

Browse files
[mypyc] feat: add CastExpr support to constant_fold_expr
1 parent c71fef0 commit 70fa984

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

mypy/constant_fold.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing import Final, Union
99

1010
from mypy.nodes import (
11+
CastExpr,
1112
ComplexExpr,
1213
Expression,
1314
FloatExpr,
@@ -73,6 +74,8 @@ def constant_fold_expr(expr: Expression, cur_mod_id: str) -> ConstantValue | Non
7374
value = constant_fold_expr(expr.expr, cur_mod_id)
7475
if value is not None:
7576
return constant_fold_unary_op(expr.op, value)
77+
elif isinstance(expr, CastExpr):
78+
return constant_fold_expr(expr.expr, cur_mod_id)
7679
return None
7780

7881

0 commit comments

Comments
 (0)