@@ -108,7 +108,9 @@ dummy_func(void) {
108108 }
109109
110110 op (_BINARY_OP_ADD_INT , (left , right -- res )) {
111- if (sym_is_const (left ) && sym_is_const (right )) {
111+ if (sym_is_const (left ) && sym_is_const (right ) &&
112+ sym_matches_type (left , & PyLong_Type ) && sym_matches_type (right , & PyLong_Type ))
113+ {
112114 assert (PyLong_CheckExact (sym_get_const (left )));
113115 assert (PyLong_CheckExact (sym_get_const (right )));
114116 PyObject * temp = _PyLong_Add ((PyLongObject * )sym_get_const (left ),
@@ -127,7 +129,9 @@ dummy_func(void) {
127129 }
128130
129131 op (_BINARY_OP_SUBTRACT_INT , (left , right -- res )) {
130- if (sym_is_const (left ) && sym_is_const (right )) {
132+ if (sym_is_const (left ) && sym_is_const (right ) &&
133+ sym_matches_type (left , & PyLong_Type ) && sym_matches_type (right , & PyLong_Type ))
134+ {
131135 assert (PyLong_CheckExact (sym_get_const (left )));
132136 assert (PyLong_CheckExact (sym_get_const (right )));
133137 PyObject * temp = _PyLong_Subtract ((PyLongObject * )sym_get_const (left ),
@@ -146,7 +150,9 @@ dummy_func(void) {
146150 }
147151
148152 op (_BINARY_OP_MULTIPLY_INT , (left , right -- res )) {
149- if (sym_is_const (left ) && sym_is_const (right )) {
153+ if (sym_is_const (left ) && sym_is_const (right ) &&
154+ sym_matches_type (left , & PyLong_Type ) && sym_matches_type (right , & PyLong_Type ))
155+ {
150156 assert (PyLong_CheckExact (sym_get_const (left )));
151157 assert (PyLong_CheckExact (sym_get_const (right )));
152158 PyObject * temp = _PyLong_Multiply ((PyLongObject * )sym_get_const (left ),
@@ -165,7 +171,9 @@ dummy_func(void) {
165171 }
166172
167173 op (_BINARY_OP_ADD_FLOAT , (left , right -- res )) {
168- if (sym_is_const (left ) && sym_is_const (right )) {
174+ if (sym_is_const (left ) && sym_is_const (right ) &&
175+ sym_matches_type (left , & PyFloat_Type ) && sym_matches_type (right , & PyFloat_Type ))
176+ {
169177 assert (PyFloat_CheckExact (sym_get_const (left )));
170178 assert (PyFloat_CheckExact (sym_get_const (right )));
171179 PyObject * temp = PyFloat_FromDouble (
@@ -185,7 +193,9 @@ dummy_func(void) {
185193 }
186194
187195 op (_BINARY_OP_SUBTRACT_FLOAT , (left , right -- res )) {
188- if (sym_is_const (left ) && sym_is_const (right )) {
196+ if (sym_is_const (left ) && sym_is_const (right ) &&
197+ sym_matches_type (left , & PyFloat_Type ) && sym_matches_type (right , & PyFloat_Type ))
198+ {
189199 assert (PyFloat_CheckExact (sym_get_const (left )));
190200 assert (PyFloat_CheckExact (sym_get_const (right )));
191201 PyObject * temp = PyFloat_FromDouble (
@@ -205,7 +215,9 @@ dummy_func(void) {
205215 }
206216
207217 op (_BINARY_OP_MULTIPLY_FLOAT , (left , right -- res )) {
208- if (sym_is_const (left ) && sym_is_const (right )) {
218+ if (sym_is_const (left ) && sym_is_const (right ) &&
219+ sym_matches_type (left , & PyFloat_Type ) && sym_matches_type (right , & PyFloat_Type ))
220+ {
209221 assert (PyFloat_CheckExact (sym_get_const (left )));
210222 assert (PyFloat_CheckExact (sym_get_const (right )));
211223 PyObject * temp = PyFloat_FromDouble (
0 commit comments