@@ -108,7 +108,9 @@ dummy_func(void) {
108
108
}
109
109
110
110
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
+ {
112
114
assert (PyLong_CheckExact (sym_get_const (left )));
113
115
assert (PyLong_CheckExact (sym_get_const (right )));
114
116
PyObject * temp = _PyLong_Add ((PyLongObject * )sym_get_const (left ),
@@ -127,7 +129,9 @@ dummy_func(void) {
127
129
}
128
130
129
131
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
+ {
131
135
assert (PyLong_CheckExact (sym_get_const (left )));
132
136
assert (PyLong_CheckExact (sym_get_const (right )));
133
137
PyObject * temp = _PyLong_Subtract ((PyLongObject * )sym_get_const (left ),
@@ -146,7 +150,9 @@ dummy_func(void) {
146
150
}
147
151
148
152
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
+ {
150
156
assert (PyLong_CheckExact (sym_get_const (left )));
151
157
assert (PyLong_CheckExact (sym_get_const (right )));
152
158
PyObject * temp = _PyLong_Multiply ((PyLongObject * )sym_get_const (left ),
@@ -165,7 +171,9 @@ dummy_func(void) {
165
171
}
166
172
167
173
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
+ {
169
177
assert (PyFloat_CheckExact (sym_get_const (left )));
170
178
assert (PyFloat_CheckExact (sym_get_const (right )));
171
179
PyObject * temp = PyFloat_FromDouble (
@@ -185,7 +193,9 @@ dummy_func(void) {
185
193
}
186
194
187
195
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
+ {
189
199
assert (PyFloat_CheckExact (sym_get_const (left )));
190
200
assert (PyFloat_CheckExact (sym_get_const (right )));
191
201
PyObject * temp = PyFloat_FromDouble (
@@ -205,7 +215,9 @@ dummy_func(void) {
205
215
}
206
216
207
217
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
+ {
209
221
assert (PyFloat_CheckExact (sym_get_const (left )));
210
222
assert (PyFloat_CheckExact (sym_get_const (right )));
211
223
PyObject * temp = PyFloat_FromDouble (
0 commit comments