Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sagex enum issue and solution #226

Closed
williamstein opened this issue Jan 28, 2007 · 1 comment
Closed

sagex enum issue and solution #226

williamstein opened this issue Jan 28, 2007 · 1 comment

Comments

@williamstein
Copy link
Contributor

The following code compiled just fine with 0.9.4.1
 
cdef extern from "whatever.h":
    ctypedef enum someenum_t:
        ENUMVALUE_1
        ENUMVALUE_2
 
cdef somefunction(someenum_t val):
    if val == ENUMVALUE_1:
        print "1"
    else:
        print "2"
 
 
With 0.9.5 it gives the following error:
/tmp/Pyrex-0.9.5/regression.pyx:8:11: Invalid types for '=='
(someenum_t, someenum_t)
 
 
 anders
 
 
_______________________________________________
Pyrex mailing list
Pyrex@lists.copyleft.no
http://lists.copyleft.no/mailman/listinfo/pyrex
--------

I wrote:
> /tmp/Pyrex-0.9.5/regression.pyx:8:11: Invalid types for '=='
> (someenum_t, someenum_t)
 
This patch seems to help, but I don't know enough pyrex internals to
tell if it is the correct solution.
 
--- Pyrex-0.9.5/Pyrex/Compiler/ExprNodes.py     2007-01-27
05:21:03.000000000 +0100
+++ Pyrex-0.9.5-enumcmpfix/Pyrex/Compiler/ExprNodes.py  2007-01-28
16:14:45.366599915 +0100
@@ -2594,6 +2594,8 @@
         elif (type1.is_numeric and type2.is_numeric
                 and op not in ('is', 'is_not')):
             return 1
+        elif (type1.is_enum and type2.is_enum):
+            return 1
         else:
             return 0
 
 
 
_______________________________________________
Pyrex mailing list
Pyrex@lists.copyleft.no
http://lists.copyleft.no/mailman/listinfo/pyrex

Component: packages: standard

Issue created by migration from https://trac.sagemath.org/ticket/226

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Aug 18, 2007

comment:1

The problem has been fixed in a previous release of cython.
cython regression.pyx now works fine.

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Aug 18, 2007
@williamstein williamstein added this to the sage-2.8.2 milestone Aug 18, 2007
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant