Commit aba4d55b authored by Mark Florisson's avatar Mark Florisson

Issue errors for fused types declarations at module level or cdef class scope

parent b69b4a5b
...@@ -1074,6 +1074,10 @@ class CVarDefNode(StatNode): ...@@ -1074,6 +1074,10 @@ class CVarDefNode(StatNode):
self.dest_scope = dest_scope self.dest_scope = dest_scope
base_type = self.base_type.analyse(env) base_type = self.base_type.analyse(env)
if base_type.is_fused and (env.is_c_class_scope or env.is_module_scope):
error(self.pos, "Fused types not allowed here")
return error_type
self.entry = None self.entry = None
visibility = self.visibility visibility = self.visibility
......
...@@ -38,6 +38,16 @@ def f(memslice_dtype_t[:, :] a): ...@@ -38,6 +38,16 @@ def f(memslice_dtype_t[:, :] a):
lambda cython.integral i: i lambda cython.integral i: i
cdef cython.floating x
cdef class Foo(object):
cdef cython.floating attr
def outer(cython.floating f):
def inner():
cdef cython.floating g
# This is all valid # This is all valid
dtype5 = fused_type(int, long, float) dtype5 = fused_type(int, long, float)
dtype6 = cython.fused_type(int, long) dtype6 = cython.fused_type(int, long)
...@@ -53,18 +63,21 @@ ctypedef fused fused2: ...@@ -53,18 +63,21 @@ ctypedef fused fused2:
func(x, y) func(x, y)
_ERRORS = u""" _ERRORS = u"""
fused_types.pyx:10:15: fused_type does not take keyword arguments 10:15: fused_type does not take keyword arguments
fused_types.pyx:15:38: Type specified multiple times 15:38: Type specified multiple times
fused_types.pyx:17:33: Cannot fuse a fused type 17:33: Cannot fuse a fused type
fused_types.pyx:26:4: Invalid use of fused types, type cannot be specialized 26:4: Invalid use of fused types, type cannot be specialized
fused_types.pyx:26:4: Not enough types specified to specialize the function, int2_t is still fused 26:4: Not enough types specified to specialize the function, int2_t is still fused
fused_types.pyx:27:4: Invalid use of fused types, type cannot be specialized 27:4: Invalid use of fused types, type cannot be specialized
fused_types.pyx:27:4: Not enough types specified to specialize the function, int2_t is still fused 27:4: Not enough types specified to specialize the function, int2_t is still fused
fused_types.pyx:28:16: Call with wrong number of arguments (expected 2, got 1) 28:16: Call with wrong number of arguments (expected 2, got 1)
fused_types.pyx:29:16: Call with wrong number of arguments (expected 2, got 3) 29:16: Call with wrong number of arguments (expected 2, got 3)
fused_types.pyx:30:4: Invalid use of fused types, type cannot be specialized 30:4: Invalid use of fused types, type cannot be specialized
fused_types.pyx:30:4: Keyword and starred arguments not allowed in cdef functions. 30:4: Keyword and starred arguments not allowed in cdef functions.
fused_types.pyx:36:6: Invalid base type for memoryview slice: int * 36:6: Invalid base type for memoryview slice: int *
fused_types.pyx:39:0: Fused lambdas not allowed 39:0: Fused lambdas not allowed
42:5: Fused types not allowed here
45:9: Fused types not allowed here
""" """
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment