Ticket #259 (new defect)

Opened 5 years ago

Last modified 4 years ago

future division not respected by C ints (including literals)

Reported by: robertwb Owned by: somebody
Priority: major Milestone: wishlist
Component: Code Generation Keywords:
Cc: haoyu

Description (last modified by dagss) (diff)

This:

from __future__ import division # or, cython3

cdef int a, b = 1, c = 2
a = b / c

should result in a compilation error. The resulting type of / with future division should be some floating point regardless of whether the input types are int.

In the generated code, this means the arguments (b and c above) must be cast to float prior to the division.

Attachments

division_cint.patch Download (1.2 KB) - added by haoyu 4 years ago.
Test cases

Change History

follow-up: ↓ 2   Changed 4 years ago by haoyu

  • cc haoyu added

Could you elaborate this? Any test case?

in reply to: ↑ 1   Changed 4 years ago by dagss

  • description modified (diff)

Replying to haoyu:

Could you elaborate this? Any test case?

  Changed 4 years ago by dagss

Hmm. It appears I modified the description instead of replying...But it fits this way as well. See the new description for a reply.

  Changed 4 years ago by haoyu

It seems this is already implemented. The example will raise an error "Cannot assign type 'double' to 'int'".

I just added some test cases. See the attached patch.

Changed 4 years ago by haoyu

Test cases

Note: See TracTickets for help on using tickets.