summaryrefslogtreecommitdiff
path: root/tests/errors
diff options
context:
space:
mode:
Diffstat (limited to 'tests/errors')
-rw-r--r--tests/errors/bufaccess_noassignT444.pyx2
-rw-r--r--tests/errors/buffertypedef_T117.pyx2
-rw-r--r--tests/errors/builtin_type_inheritance.pyx4
-rw-r--r--tests/errors/callingnonexisting_T307.pyx2
-rw-r--r--tests/errors/cdef_class_properties_decorated.pyx2
-rw-r--r--tests/errors/cdef_func_decorators.pyx39
-rw-r--r--tests/errors/cdef_members_T517.pyx2
-rw-r--r--tests/errors/cdefkwargs.pyx4
-rw-r--r--tests/errors/cfunc_directive_in_pyclass.pyx2
-rw-r--r--tests/errors/cfuncptr.pyx54
-rw-r--r--tests/errors/cimport_attributes.pyx9
-rw-r--r--tests/errors/compile_time_unraisable_T370.pyx2
-rw-r--r--tests/errors/const_decl_errors.pyx17
-rw-r--r--tests/errors/cpdef_vars.pyx12
-rw-r--r--tests/errors/cpp_bool.pyx2
-rw-r--r--tests/errors/cpp_enum_redeclare.pyx13
-rw-r--r--tests/errors/cpp_increment.pyx33
-rw-r--r--tests/errors/cpp_no_const_iterator_conversion.pyx62
-rw-r--r--tests/errors/cpp_object_template.pyx11
-rw-r--r--tests/errors/cpp_rvalue_reference_support.pyx32
-rw-r--r--tests/errors/cppexc_non_extern.pyx22
-rw-r--r--tests/errors/dataclass_e1.pyx22
-rw-r--r--tests/errors/dataclass_e2.pyx13
-rw-r--r--tests/errors/dataclass_e3.pyx13
-rw-r--r--tests/errors/dataclass_e4.pyx11
-rw-r--r--tests/errors/dataclass_e5.pyx21
-rw-r--r--tests/errors/dataclass_e6.pyx23
-rw-r--r--tests/errors/dataclass_w1.pyx13
-rw-r--r--tests/errors/dataclass_w1_othermod.pxd3
-rw-r--r--tests/errors/declareafteruse_T158.pyx37
-rw-r--r--tests/errors/duplicate_const.pyx13
-rw-r--r--tests/errors/e2_packedstruct_T290.pyx2
-rw-r--r--tests/errors/e_argdefault.pyx20
-rw-r--r--tests/errors/e_assert.pyx25
-rw-r--r--tests/errors/e_autotestdict.pyx2
-rw-r--r--tests/errors/e_binop_and.pyx14
-rw-r--r--tests/errors/e_binop_or.pyx14
-rw-r--r--tests/errors/e_bufaccess.pyx2
-rw-r--r--tests/errors/e_cdef_keywords_T241.pyx2
-rw-r--r--tests/errors/e_cdefemptysue.pyx13
-rw-r--r--tests/errors/e_cenum_with_type.pyx8
-rw-r--r--tests/errors/e_cpp_only_features.pyx2
-rw-r--r--tests/errors/e_cpp_references.pyx10
-rw-r--r--tests/errors/e_cstruct.pyx2
-rw-r--r--tests/errors/e_decorators.pyx13
-rw-r--r--tests/errors/e_excvalfunctype.pyx2
-rw-r--r--tests/errors/e_exttype_total_ordering.pyx178
-rw-r--r--tests/errors/e_int_literals_py2.py2
-rw-r--r--tests/errors/e_invalid_special_cython_modules.py46
-rw-r--r--tests/errors/e_nogilfunctype.pyx2
-rw-r--r--tests/errors/e_public_cdef_private_types.pyx4
-rw-r--r--tests/errors/e_pure_cimports.pyx32
-rw-r--r--tests/errors/e_relative_cimport.pyx4
-rw-r--r--tests/errors/e_tuple_args_T692.py3
-rw-r--r--tests/errors/e_typing_errors.pyx59
-rw-r--r--tests/errors/e_typing_optional.py43
-rw-r--r--tests/errors/fused_types.pyx41
-rw-r--r--tests/errors/incomplete_varadic.pyx8
-rw-r--r--tests/errors/missing_baseclass_in_predecl_T262.pyx2
-rw-r--r--tests/errors/missing_self_in_cpdef_method_T156.pyx2
-rw-r--r--tests/errors/missing_self_in_cpdef_method_T165.pyx2
-rw-r--r--tests/errors/nogil.pyx52
-rw-r--r--tests/errors/nogil_conditional.pyx81
-rw-r--r--tests/errors/nogilfunctype.pyx2
-rw-r--r--tests/errors/nonconst_excval.pyx12
-rw-r--r--tests/errors/notcimportedT418.pyx2
-rw-r--r--tests/errors/pep487_exttype.pyx13
-rw-r--r--tests/errors/pep492_badsyntax_async2.pyx11
-rw-r--r--tests/errors/posonly.pyx102
-rw-r--r--tests/errors/posonly2.pyx9
-rw-r--r--tests/errors/posonly3.pyx13
-rw-r--r--tests/errors/posonly4.pyx9
-rw-r--r--tests/errors/posonly5.pyx11
-rw-r--r--tests/errors/pure_errors.py37
-rw-r--r--tests/errors/pure_warnings.py63
-rw-r--r--tests/errors/pxd_cdef_class_declaration_T286.pyx2
-rw-r--r--tests/errors/pyobjcastdisallow_T313.pyx2
-rw-r--r--tests/errors/redeclaration_of_var_by_cfunc_T600.pyx14
-rw-r--r--tests/errors/return_outside_function_T135.pyx2
-rw-r--r--tests/errors/reversed_literal_pyobjs.pyx5
-rw-r--r--tests/errors/tree_assert.pyx8
-rw-r--r--tests/errors/typoT304.pyx2
-rw-r--r--tests/errors/unicode_identifiers_e1.pyx8
-rw-r--r--tests/errors/unicode_identifiers_e2.pyx9
-rw-r--r--tests/errors/unicode_identifiers_e3.pyx11
-rw-r--r--tests/errors/unicode_identifiers_e4.pyx13
-rw-r--r--tests/errors/uninitialized_lhs.pyx2
-rw-r--r--tests/errors/w_numpy_arr_as_cppvec_ref.pyx12
-rw-r--r--tests/errors/w_uninitialized.pyx4
89 files changed, 1418 insertions, 149 deletions
diff --git a/tests/errors/bufaccess_noassignT444.pyx b/tests/errors/bufaccess_noassignT444.pyx
index 44d2ebd0b..c618106fb 100644
--- a/tests/errors/bufaccess_noassignT444.pyx
+++ b/tests/errors/bufaccess_noassignT444.pyx
@@ -1,4 +1,4 @@
-# ticket: 444
+# ticket: t444
# mode: error
def test():
diff --git a/tests/errors/buffertypedef_T117.pyx b/tests/errors/buffertypedef_T117.pyx
index d88a3895b..cefa79939 100644
--- a/tests/errors/buffertypedef_T117.pyx
+++ b/tests/errors/buffertypedef_T117.pyx
@@ -1,4 +1,4 @@
-# ticket: 117
+# ticket: t117
# mode: error
ctypedef object[float] mybuffer
diff --git a/tests/errors/builtin_type_inheritance.pyx b/tests/errors/builtin_type_inheritance.pyx
index 1c6ad31e1..a85f7a133 100644
--- a/tests/errors/builtin_type_inheritance.pyx
+++ b/tests/errors/builtin_type_inheritance.pyx
@@ -8,11 +8,9 @@ cdef class MyTuple(tuple):
cdef class MyBytes(bytes):
pass
-cdef class MyStr(str): # only in Py2, but can't know that during compilation
- pass
+# str is also included in this in Py2, but checked at runtime instead
_ERRORS = """
5:19: inheritance from PyVarObject types like 'tuple' is not currently supported
8:19: inheritance from PyVarObject types like 'bytes' is not currently supported
-11:17: inheritance from PyVarObject types like 'str' is not currently supported
"""
diff --git a/tests/errors/callingnonexisting_T307.pyx b/tests/errors/callingnonexisting_T307.pyx
index e9409fcab..ac767e581 100644
--- a/tests/errors/callingnonexisting_T307.pyx
+++ b/tests/errors/callingnonexisting_T307.pyx
@@ -1,4 +1,4 @@
-# ticket: 307
+# ticket: t307
# mode: error
nonexisting(3, with_kw_arg=4)
diff --git a/tests/errors/cdef_class_properties_decorated.pyx b/tests/errors/cdef_class_properties_decorated.pyx
index 7485d8891..f796b7128 100644
--- a/tests/errors/cdef_class_properties_decorated.pyx
+++ b/tests/errors/cdef_class_properties_decorated.pyx
@@ -1,5 +1,5 @@
# mode: error
-# ticket: 264
+# ticket: t264
# tag: property, decorator
diff --git a/tests/errors/cdef_func_decorators.pyx b/tests/errors/cdef_func_decorators.pyx
new file mode 100644
index 000000000..e249b2e97
--- /dev/null
+++ b/tests/errors/cdef_func_decorators.pyx
@@ -0,0 +1,39 @@
+# mode: error
+# tag: decorator
+
+from functools import wraps
+
+@wraps
+cdef cant_be_decoratored():
+ pass
+
+@wraps
+cpdef also_cant_be_decorated():
+ pass
+
+cdef class C:
+ @wraps
+ cdef still_cant_be_decorated(self):
+ pass
+
+ @property
+ cdef property_only_works_for_extern_classes(self):
+ pass
+
+ @wraps
+ cpdef also_still_cant_be_decorated(self):
+ pass
+
+ @wraps
+ @wraps
+ cdef two_is_just_as_bad_as_one(self):
+ pass
+
+_ERRORS = """
+6:0: Cdef functions cannot take arbitrary decorators.
+10:0: Cdef functions cannot take arbitrary decorators.
+15:4: Cdef functions cannot take arbitrary decorators.
+19:4: Cdef functions cannot take arbitrary decorators.
+23:4: Cdef functions cannot take arbitrary decorators.
+27:4: Cdef functions cannot take arbitrary decorators.
+"""
diff --git a/tests/errors/cdef_members_T517.pyx b/tests/errors/cdef_members_T517.pyx
index 9bd3b111c..34bfd79fd 100644
--- a/tests/errors/cdef_members_T517.pyx
+++ b/tests/errors/cdef_members_T517.pyx
@@ -1,4 +1,4 @@
-# ticket: 517
+# ticket: t517
# mode: error
ctypedef void* VoidP
diff --git a/tests/errors/cdefkwargs.pyx b/tests/errors/cdefkwargs.pyx
index a4477e2da..2fedeb04a 100644
--- a/tests/errors/cdefkwargs.pyx
+++ b/tests/errors/cdefkwargs.pyx
@@ -6,10 +6,6 @@ __doc__ = u"""
>>> call4()
"""
-import sys, re
-if sys.version_info >= (2,6):
- __doc__ = re.sub(u"Error: (.*)exactly(.*)", u"Error: \\1at most\\2", __doc__)
-
# the calls:
def call2():
diff --git a/tests/errors/cfunc_directive_in_pyclass.pyx b/tests/errors/cfunc_directive_in_pyclass.pyx
index bb12dc271..d6b373a40 100644
--- a/tests/errors/cfunc_directive_in_pyclass.pyx
+++ b/tests/errors/cfunc_directive_in_pyclass.pyx
@@ -7,5 +7,5 @@ class Pyclass(object):
pass
_ERRORS = """
- 6:4: cfunc directive is not allowed here
+ 5:4: cfunc directive is not allowed here
"""
diff --git a/tests/errors/cfuncptr.pyx b/tests/errors/cfuncptr.pyx
new file mode 100644
index 000000000..9b5f12644
--- /dev/null
+++ b/tests/errors/cfuncptr.pyx
@@ -0,0 +1,54 @@
+# mode: error
+
+cdef int exceptmaybeminus2(int bad) except ?-2:
+ if bad:
+ raise RuntimeError
+ else:
+ return 0
+
+def fail_exceptmaybeminus2(bad):
+ cdef int (*fptr_a)(int) except -2
+ cdef int (*fptr_b)(int) except -1
+ cdef int (*fptr_c)(int) except ?-1
+ fptr_a = exceptmaybeminus2
+ fptr_b = exceptmaybeminus2
+ fptr_c = exceptmaybeminus2
+
+cdef extern from *:
+ # define this as extern since Cython converts internal "except*" to "except -1"
+ cdef int exceptstar(int bad) except *
+
+ struct mystruct:
+ int (*func_ptr)(int param) nogil
+ void (*func_ptr_void)(int param) nogil
+
+def fail_exceptstar(bad):
+ cdef int (*fptr_a)(int) noexcept
+ cdef int (*fptr_b)(int) except -1
+ cdef int (*fptr_c)(int) except ?-1
+ fptr_a = exceptstar
+ fptr_b = exceptstar
+ fptr_c = exceptstar
+
+cdef int cb(int param) nogil:
+ return param
+
+cdef void cb_void(int param) except * nogil:
+ return
+
+def fail_struct_pointer():
+ cdef mystruct ms = mystruct(&cb, &cb_void)
+
+
+_ERRORS = """
+13:13: Cannot assign type 'int (int) except? -2' to 'int (*)(int) except -2'
+14:13: Cannot assign type 'int (int) except? -2' to 'int (*)(int) except -1'
+15:13: Cannot assign type 'int (int) except? -2' to 'int (*)(int) except? -1'
+29:13: Cannot assign type 'int (int) except *' to 'int (*)(int) noexcept'
+30:13: Cannot assign type 'int (int) except *' to 'int (*)(int) except -1'
+31:13: Cannot assign type 'int (int) except *' to 'int (*)(int) except? -1'
+40:32: Cannot assign type 'int (*)(int) except? -1 nogil' to 'int (*)(int) noexcept nogil'
+40:32: Cannot assign type 'int (*)(int) except? -1 nogil' to 'int (*)(int) noexcept nogil'
+40:37: Cannot assign type 'void (*)(int) except * nogil' to 'void (*)(int) noexcept nogil'
+40:37: Cannot assign type 'void (*)(int) except * nogil' to 'void (*)(int) noexcept nogil'
+"""
diff --git a/tests/errors/cimport_attributes.pyx b/tests/errors/cimport_attributes.pyx
index 53e303a42..7037b9aa3 100644
--- a/tests/errors/cimport_attributes.pyx
+++ b/tests/errors/cimport_attributes.pyx
@@ -1,4 +1,5 @@
# mode: error
+# tag: cpp
cimport libcpp
@@ -24,8 +25,8 @@ print my_map_with_shadow.python_attribute # OK (if such a module existed at ru
_ERRORS = u"""
-5:12: cimported module has no attribute 'no_such_attribute'
-8:16: cimported module has no attribute 'no_such_attribute'
-11:12: cimported module has no attribute 'no_such_attribute'
-14:15: cimported module has no attribute 'no_such_attribute'
+6:12: cimported module has no attribute 'no_such_attribute'
+9:16: cimported module has no attribute 'no_such_attribute'
+12:12: cimported module has no attribute 'no_such_attribute'
+15:15: cimported module has no attribute 'no_such_attribute'
"""
diff --git a/tests/errors/compile_time_unraisable_T370.pyx b/tests/errors/compile_time_unraisable_T370.pyx
index 963f280fb..d22f0c6c0 100644
--- a/tests/errors/compile_time_unraisable_T370.pyx
+++ b/tests/errors/compile_time_unraisable_T370.pyx
@@ -1,4 +1,4 @@
-# ticket: 370
+# ticket: t370
# mode: error
cdef int raiseit():
diff --git a/tests/errors/const_decl_errors.pyx b/tests/errors/const_decl_errors.pyx
index 459480adb..29c9896ea 100644
--- a/tests/errors/const_decl_errors.pyx
+++ b/tests/errors/const_decl_errors.pyx
@@ -10,23 +10,34 @@ cdef const int x = 10
cdef struct S:
int member
-cdef func(const int a, const int* b, const (int*) c, const S s, int *const d,
+cdef func(const int a, const int* b, const (int*) c, const S s, int *const d, int **const e, int *const *f,
const S *const t):
a = 10
c = NULL
b[0] = 100
s.member = 1000
d = NULL
+ e[0][0] = 1 # ok
+ e[0] = NULL # ok
+ e = NULL # nok
+ f[0][0] = 1 # ok
+ f[0] = NULL # nok
+ f = NULL # ok
t = &s
+cdef volatile object v
+
_ERRORS = """
-3:5: Const base type cannot be a Python object
+3:5: Const/volatile base type cannot be a Python object
8:5: Assignment to const 'x'
15:4: Assignment to const 'a'
16:4: Assignment to const 'c'
17:5: Assignment to const dereference
18:5: Assignment to const attribute 'member'
19:4: Assignment to const 'd'
-20:4: Assignment to const 't'
+22:4: Assignment to const 'e'
+24:5: Assignment to const dereference
+26:4: Assignment to const 't'
+28:5: Const/volatile base type cannot be a Python object
"""
diff --git a/tests/errors/cpdef_vars.pyx b/tests/errors/cpdef_vars.pyx
index f356decfc..b317d15b0 100644
--- a/tests/errors/cpdef_vars.pyx
+++ b/tests/errors/cpdef_vars.pyx
@@ -1,4 +1,4 @@
-# tag: warnings
+# mode: error
cpdef str a = "123"
cpdef b = 2
@@ -16,9 +16,9 @@ def func():
return d
-_WARNINGS = """
-3:6: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
-4:6: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
-7:10: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
-15:10: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables
+_ERRORS = """
+3:6: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
+4:6: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
+7:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
+15:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
"""
diff --git a/tests/errors/cpp_bool.pyx b/tests/errors/cpp_bool.pyx
index 15fa4d510..11b0d5c2f 100644
--- a/tests/errors/cpp_bool.pyx
+++ b/tests/errors/cpp_bool.pyx
@@ -5,7 +5,7 @@ from libcpp.string cimport string
cdef foo():
cdef string field
- if field: # field cannot be coerced to book
+ if field: # field cannot be coerced to bool
pass
_ERRORS = u"""
diff --git a/tests/errors/cpp_enum_redeclare.pyx b/tests/errors/cpp_enum_redeclare.pyx
new file mode 100644
index 000000000..3d2ae7763
--- /dev/null
+++ b/tests/errors/cpp_enum_redeclare.pyx
@@ -0,0 +1,13 @@
+# mode: error
+# tag: cpp
+
+cdef enum class Spam:
+ a
+
+cdef enum class Spam:
+ b
+
+_ERRORS="""
+7:5: 'Spam' redeclared
+4:5: Previous declaration is here
+"""
diff --git a/tests/errors/cpp_increment.pyx b/tests/errors/cpp_increment.pyx
new file mode 100644
index 000000000..45e978d95
--- /dev/null
+++ b/tests/errors/cpp_increment.pyx
@@ -0,0 +1,33 @@
+# mode: error
+
+cimport cython
+
+cdef extern from *:
+ cdef cppclass Foo:
+ Foo operator++()
+ Foo operator--()
+
+ cdef cppclass Bar:
+ Bar operator++(int)
+ Bar operator--(int)
+
+cdef void foo():
+ cdef Foo f
+ cdef Bar b
+ cython.operator.postincrement(f)
+ cython.operator.postincrement(b)
+ cython.operator.postdecrement(f)
+ cython.operator.postdecrement(b)
+
+ cython.operator.preincrement(f)
+ cython.operator.preincrement(b)
+ cython.operator.predecrement(f)
+ cython.operator.predecrement(b)
+
+
+_ERRORS = u"""
+17:19: No 'operator++(int)' declared for postfix '++' (operand type is 'Foo')
+19:19: No 'operator--(int)' declared for postfix '--' (operand type is 'Foo')
+23:19: No match for 'operator++' (operand type is 'Bar')
+25:19: No match for 'operator--' (operand type is 'Bar')
+"""
diff --git a/tests/errors/cpp_no_const_iterator_conversion.pyx b/tests/errors/cpp_no_const_iterator_conversion.pyx
new file mode 100644
index 000000000..9772e094a
--- /dev/null
+++ b/tests/errors/cpp_no_const_iterator_conversion.pyx
@@ -0,0 +1,62 @@
+# mode: error
+# tag: cpp
+
+from libcpp.deque cimport deque
+from libcpp.list cimport list
+from libcpp.map cimport map
+from libcpp.set cimport set
+from libcpp.string cimport string
+from libcpp.unordered_map cimport unordered_map
+from libcpp.unordered_set cimport unordered_set
+from libcpp.vector cimport vector
+
+def deque_iterator():
+ cdef deque[int].iterator begin
+ cdef deque[int].const_iterator cbegin = begin
+ begin = cbegin
+
+def list_iterator():
+ cdef list[int].iterator begin
+ cdef list[int].const_iterator cbegin = begin
+ begin = cbegin
+
+def map_iterator():
+ cdef map[int, int].iterator begin
+ cdef map[int, int].const_iterator cbegin = begin
+ begin = cbegin
+
+def set_iterator():
+ cdef set[int].iterator begin
+ cdef set[int].const_iterator cbegin = begin
+ begin = cbegin
+
+def string_iterator():
+ cdef string.iterator begin
+ cdef string.const_iterator cbegin = begin
+ begin = cbegin
+
+def map_iterator():
+ cdef unordered_map[int, int].iterator begin
+ cdef unordered_map[int, int].const_iterator cbegin = begin
+ begin = cbegin
+
+def set_iterator():
+ cdef unordered_set[int].iterator begin
+ cdef unordered_set[int].const_iterator cbegin = begin
+ begin = cbegin
+
+def vector_iterator():
+ cdef vector[int].iterator begin
+ cdef vector[int].const_iterator cbegin = begin
+ begin = cbegin
+
+_ERRORS = u"""
+16:12: Cannot assign type 'const_iterator' to 'iterator'
+21:12: Cannot assign type 'const_iterator' to 'iterator'
+26:12: Cannot assign type 'const_iterator' to 'iterator'
+31:12: Cannot assign type 'const_iterator' to 'iterator'
+36:12: Cannot assign type 'const_iterator' to 'iterator'
+41:12: Cannot assign type 'const_iterator' to 'iterator'
+46:12: Cannot assign type 'const_iterator' to 'iterator'
+51:12: Cannot assign type 'const_iterator' to 'iterator'
+"""
diff --git a/tests/errors/cpp_object_template.pyx b/tests/errors/cpp_object_template.pyx
index a90bdedff..e1a15c905 100644
--- a/tests/errors/cpp_object_template.pyx
+++ b/tests/errors/cpp_object_template.pyx
@@ -1,4 +1,5 @@
# mode: error
+# tag: cpp
from libcpp.vector cimport vector
@@ -11,7 +12,13 @@ def main():
cdef vector[A] va
va.push_back(A())
+def memview():
+ import array
+ cdef vector[int[:]] vmv
+ vmv.push_back(array.array("i", [1,2,3]))
+
_ERRORS = u"""
-9:16: Python object type 'Python object' cannot be used as a template argument
-11:16: Python object type 'A' cannot be used as a template argument
+10:15: Python object type 'Python object' cannot be used as a template argument
+12:15: Python object type 'A' cannot be used as a template argument
+17:15: Reference-counted type 'int[:]' cannot be used as a template argument
"""
diff --git a/tests/errors/cpp_rvalue_reference_support.pyx b/tests/errors/cpp_rvalue_reference_support.pyx
new file mode 100644
index 000000000..e1e7015c9
--- /dev/null
+++ b/tests/errors/cpp_rvalue_reference_support.pyx
@@ -0,0 +1,32 @@
+# mode: error
+# tag: werror, cpp, cpp11
+
+# These tests check for unsupported use of rvalue-references (&&)
+# and should be removed or cleaned up when support is added.
+
+cdef int&& x
+
+cdef void foo(int&& x):
+ pass
+
+cdef int&& bar():
+ pass
+
+cdef extern from *:
+ """
+ void baz(int x, int&& y) {}
+
+ template <typename T>
+ void qux(const T&& x) {}
+ """
+ cdef void baz(int x, int&& y)
+ cdef void qux[T](const T&& x)
+
+
+_ERRORS="""
+7:8: C++ rvalue-references cannot be declared
+9:13: Rvalue-reference as function argument not supported
+12:14: Rvalue-reference as function return type not supported
+22:17: Rvalue-reference as function argument not supported
+23:20: Rvalue-reference as function argument not supported
+"""
diff --git a/tests/errors/cppexc_non_extern.pyx b/tests/errors/cppexc_non_extern.pyx
new file mode 100644
index 000000000..f498e398d
--- /dev/null
+++ b/tests/errors/cppexc_non_extern.pyx
@@ -0,0 +1,22 @@
+# mode: error
+# tag: warnings
+
+cdef inline void handle_exception():
+ pass
+
+# GH 3064 - cppfunc caused invalid code to be generated with +handle_exception
+# error to prevent this
+cdef test_func1(self) except +handle_exception:
+ pass
+
+# warning
+cdef test_func2(self) except +:
+ pass
+
+_ERRORS = """
+9:5: Only extern functions can throw C++ exceptions.
+"""
+
+_WARNINGS = """
+13:5: Only extern functions can throw C++ exceptions.
+"""
diff --git a/tests/errors/dataclass_e1.pyx b/tests/errors/dataclass_e1.pyx
new file mode 100644
index 000000000..95d67ad7d
--- /dev/null
+++ b/tests/errors/dataclass_e1.pyx
@@ -0,0 +1,22 @@
+# mode: error
+# tag: warnings
+cimport cython
+
+@cython.dataclasses.dataclass(1, shouldnt_be_here=True, init=5, unsafe_hash=True)
+cdef class C:
+ a: list = [] # mutable
+ b: int = cython.dataclasses.field(default=5, default_factory=int)
+ c: int
+
+ def __hash__(self):
+ pass
+
+_ERRORS = """
+6:5: Arguments passed to cython.dataclasses.dataclass must be True or False
+6:5: Cannot overwrite attribute __hash__ in class C
+6:5: cython.dataclasses.dataclass() got an unexpected keyword argument 'shouldnt_be_here'
+6:5: cython.dataclasses.dataclass takes no positional arguments
+7:14: mutable default <class 'list'> for field a is not allowed: use default_factory
+8:37: cannot specify both default and default_factory
+9:4: non-default argument 'c' follows default argument in dataclass __init__
+"""
diff --git a/tests/errors/dataclass_e2.pyx b/tests/errors/dataclass_e2.pyx
new file mode 100644
index 000000000..e25965938
--- /dev/null
+++ b/tests/errors/dataclass_e2.pyx
@@ -0,0 +1,13 @@
+# mode: error
+# tag: dataclass
+
+import dataclasses
+
+@dataclasses.dataclass
+cdef class C:
+ pass
+
+_ERRORS = """
+6:0: Cdef functions/classes cannot take arbitrary decorators.
+6:0: Use '@cython.dataclasses.dataclass' on cdef classes to create a dataclass
+"""
diff --git a/tests/errors/dataclass_e3.pyx b/tests/errors/dataclass_e3.pyx
new file mode 100644
index 000000000..85a900172
--- /dev/null
+++ b/tests/errors/dataclass_e3.pyx
@@ -0,0 +1,13 @@
+# mode: compile
+# tag: dataclass, warnings
+
+cimport cython
+from dataclass import field
+
+@cython.dataclasses.dataclass
+cdef class E:
+ a: int = field()
+
+_WARNINGS="""
+9:18: Do you mean cython.dataclasses.field instead?
+"""
diff --git a/tests/errors/dataclass_e4.pyx b/tests/errors/dataclass_e4.pyx
new file mode 100644
index 000000000..007487bb8
--- /dev/null
+++ b/tests/errors/dataclass_e4.pyx
@@ -0,0 +1,11 @@
+# mode: error
+
+cimport cython
+
+@cython.dataclasses.dataclass
+cdef class C:
+ a: int = cython.dataclasses.field(unexpected=True)
+
+_ERRORS = """
+7:49: cython.dataclasses.field() got an unexpected keyword argument 'unexpected'
+"""
diff --git a/tests/errors/dataclass_e5.pyx b/tests/errors/dataclass_e5.pyx
new file mode 100644
index 000000000..3d9028954
--- /dev/null
+++ b/tests/errors/dataclass_e5.pyx
@@ -0,0 +1,21 @@
+# mode: error
+# tag: warnings
+
+cimport cython
+
+@cython.dataclasses.dataclass
+cdef class C:
+ a: int
+ b: long
+ c: Py_ssize_t
+ d: float
+ e: double
+
+
+_WARNINGS = """
+9:7: Found Python 2.x type 'long' in a Python annotation. Did you mean to use 'cython.long'?
+10:7: Found C type 'Py_ssize_t' in a Python annotation. Did you mean to use 'cython.Py_ssize_t'?
+10:7: Unknown type declaration 'Py_ssize_t' in annotation, ignoring
+12:7: Found C type 'double' in a Python annotation. Did you mean to use 'cython.double'?
+12:7: Unknown type declaration 'double' in annotation, ignoring
+"""
diff --git a/tests/errors/dataclass_e6.pyx b/tests/errors/dataclass_e6.pyx
new file mode 100644
index 000000000..64dc1ae05
--- /dev/null
+++ b/tests/errors/dataclass_e6.pyx
@@ -0,0 +1,23 @@
+# mode: error
+
+from cython.dataclasses cimport dataclass
+
+@dataclass
+cdef class BaseDataclass:
+ a: str = "value"
+
+@dataclass
+cdef class MainDataclass(BaseDataclass):
+ a: str = "new value"
+
+cdef class Intermediate(BaseDataclass):
+ pass
+
+@dataclass
+cdef class AnotherDataclass(Intermediate):
+ a: str = "ooops"
+
+_ERRORS = """
+11:4: Cannot redeclare inherited fields in Cython dataclasses
+18:4: Cannot redeclare inherited fields in Cython dataclasses
+"""
diff --git a/tests/errors/dataclass_w1.pyx b/tests/errors/dataclass_w1.pyx
new file mode 100644
index 000000000..c0d9790e2
--- /dev/null
+++ b/tests/errors/dataclass_w1.pyx
@@ -0,0 +1,13 @@
+# mode: compile
+# tag: warnings
+
+from dataclass_w1_othermod cimport SomeBase
+from cython.dataclasses cimport dataclass
+
+@dataclass
+cdef class DC(SomeBase):
+ a: str = ""
+
+_WARNINGS = """
+8:5: Cannot reliably handle Cython dataclasses with base types in external modules since it is not possible to tell what fields they have
+"""
diff --git a/tests/errors/dataclass_w1_othermod.pxd b/tests/errors/dataclass_w1_othermod.pxd
new file mode 100644
index 000000000..02dddf492
--- /dev/null
+++ b/tests/errors/dataclass_w1_othermod.pxd
@@ -0,0 +1,3 @@
+# Extern class for test "dataclass_w1"
+cdef class SomeBase:
+ pass
diff --git a/tests/errors/declareafteruse_T158.pyx b/tests/errors/declareafteruse_T158.pyx
index 34e5f097e..a6ff6da13 100644
--- a/tests/errors/declareafteruse_T158.pyx
+++ b/tests/errors/declareafteruse_T158.pyx
@@ -1,4 +1,4 @@
-# ticket: 158
+# ticket: t158
# mode: error
def mult_decl_test():
@@ -52,26 +52,19 @@ cdef int *baz
print var[0][0]
cdef unsigned long long[100][100] var
-# in 0.11.1 these are warnings
-FUTURE_ERRORS = u"""
-6:13: cdef variable 's' declared after it is used
-6:16: cdef variable 'vv' declared after it is used
-11:14: cdef variable 'i' declared after it is used
-17:14: cdef variable 'i' declared after it is used
-23:14: cdef variable 'i' declared after it is used
-26:9: cdef variable 's' declared after it is used
-32:17: cdef variable 't' declared after it is used
-36:13: cdef variable 'r' declared after it is used
-42:17: cdef variable 't' declared after it is used
-49:10: cdef variable 'baz' declared after it is used
-52:24: cdef variable 'var' declared after it is used
-"""
-
-syntax error
-
_ERRORS = u"""
-42:17: cdef variable 't' declared after it is used
-49:10: cdef variable 'baz' declared after it is used
-52:24: cdef variable 'var' declared after it is used
-70:7: Syntax error in simple statement list
+5:17: local variable 'vv' referenced before assignment
+6:17: local variable 's' referenced before assignment
+7:13: cdef variable 's' declared after it is used
+7:16: cdef variable 'vv' declared after it is used
+12:14: cdef variable 'i' declared after it is used
+18:14: cdef variable 'i' declared after it is used
+24:14: cdef variable 'i' declared after it is used
+27:9: cdef variable 's' declared after it is used
+33:17: cdef variable 't' declared after it is used
+43:17: cdef variable 't' declared after it is used
+50:10: cdef variable 'baz' declared after it is used
+53:34: cdef variable 'var' declared after it is used
"""
+# FIXME not detected
+#37:13: cdef variable 'r' declared after it is used
diff --git a/tests/errors/duplicate_const.pyx b/tests/errors/duplicate_const.pyx
new file mode 100644
index 000000000..1367dd13b
--- /dev/null
+++ b/tests/errors/duplicate_const.pyx
@@ -0,0 +1,13 @@
+# mode: error
+
+cdef extern from *:
+ cdef const const int a
+ cdef const volatile int b
+ cdef volatile const int c
+ cdef volatile volatile int d
+
+
+_ERRORS = """
+4:9: Duplicate 'const'
+7:9: Duplicate 'volatile'
+"""
diff --git a/tests/errors/e2_packedstruct_T290.pyx b/tests/errors/e2_packedstruct_T290.pyx
index 1a0f40f18..084b36d71 100644
--- a/tests/errors/e2_packedstruct_T290.pyx
+++ b/tests/errors/e2_packedstruct_T290.pyx
@@ -1,4 +1,4 @@
-# ticket: 290
+# ticket: t290
# mode: error
cdef packed foo:
diff --git a/tests/errors/e_argdefault.pyx b/tests/errors/e_argdefault.pyx
index d8828741f..afcf0e325 100644
--- a/tests/errors/e_argdefault.pyx
+++ b/tests/errors/e_argdefault.pyx
@@ -1,19 +1,27 @@
# mode: error
cdef spam(int i, char *s = "blarg", float f): # can't have default value
- pass
+ pass
def swallow(x, y = 42, z): # non-default after default
- pass
+ pass
cdef class Grail:
- def __add__(x, y = 42): # can't have default value
- pass
+ def __add__(x, y = 42): # can't have default value
+ pass
+
+ def __pow__(x, y, z=10): # default must be None
+ pass
+
+ def __rpow__(x, y=2, z=None): # z is OK, y isn't
+ pass
_ERRORS = u"""
-3:10: Non-default argument follows default argument
+3:9: Non-default argument follows default argument
3:36: Non-default argument following default argument
6:23: Non-default argument following default argument
-11:16: This argument cannot have a default value
+11:19: This argument cannot have a default value
+14:22: This argument cannot have a non-None default value
+17:20: This argument cannot have a default value
"""
diff --git a/tests/errors/e_assert.pyx b/tests/errors/e_assert.pyx
new file mode 100644
index 000000000..616d86ff1
--- /dev/null
+++ b/tests/errors/e_assert.pyx
@@ -0,0 +1,25 @@
+# mode: error
+# tag: assert
+
+def nontrivial_assert_in_nogil(int a, obj):
+ with nogil:
+ # NOK
+ assert obj
+ assert a*obj
+ assert obj, "abc"
+
+ # OK
+ assert a
+ assert a*a
+ assert a, "abc"
+ assert a, u"abc"
+ assert a, f"123{a}xyz"
+
+
+_ERRORS = """
+7:15: Truth-testing Python object not allowed without gil
+8:15: Converting to Python object not allowed without gil
+8:16: Operation not allowed without gil
+8:16: Truth-testing Python object not allowed without gil
+9:15: Truth-testing Python object not allowed without gil
+"""
diff --git a/tests/errors/e_autotestdict.pyx b/tests/errors/e_autotestdict.pyx
index a5d56f3d2..097b09fb2 100644
--- a/tests/errors/e_autotestdict.pyx
+++ b/tests/errors/e_autotestdict.pyx
@@ -7,5 +7,5 @@ def foo():
pass
_ERRORS = u"""
-6:0: The autotestdict compiler directive is not allowed in function scope
+5:0: The autotestdict compiler directive is not allowed in function scope
"""
diff --git a/tests/errors/e_binop_and.pyx b/tests/errors/e_binop_and.pyx
new file mode 100644
index 000000000..195677bdf
--- /dev/null
+++ b/tests/errors/e_binop_and.pyx
@@ -0,0 +1,14 @@
+# mode: error
+# tag: and, binop, warnings
+
+def test_and(a, b):
+ return a && b
+
+
+_WARNINGS = """
+5:13: Found the C operator '&&', did you mean the Python operator 'and'?
+"""
+
+_ERRORS = """
+5:13: Syntax error in simple statement list
+"""
diff --git a/tests/errors/e_binop_or.pyx b/tests/errors/e_binop_or.pyx
new file mode 100644
index 000000000..1e4109244
--- /dev/null
+++ b/tests/errors/e_binop_or.pyx
@@ -0,0 +1,14 @@
+# mode: error
+# tag: or, binop, warnings
+
+def test_or(a, b):
+ return a || b
+
+
+_WARNINGS = """
+5:13: Found the C operator '||', did you mean the Python operator 'or'?
+"""
+
+_ERRORS = """
+5:13: Syntax error in simple statement list
+"""
diff --git a/tests/errors/e_bufaccess.pyx b/tests/errors/e_bufaccess.pyx
index bc5b9c0f3..5be4876d5 100644
--- a/tests/errors/e_bufaccess.pyx
+++ b/tests/errors/e_bufaccess.pyx
@@ -17,7 +17,7 @@ def f():
_ERRORS = u"""
3:17: Buffer types only allowed as function local variables
5:21: Buffer types only allowed as function local variables
-8:31: "fakeoption" is not a buffer option
+8:27: "fakeoption" is not a buffer option
"""
#TODO:
#7:22: "ndim" must be non-negative
diff --git a/tests/errors/e_cdef_keywords_T241.pyx b/tests/errors/e_cdef_keywords_T241.pyx
index 87524ebdd..28a2783fe 100644
--- a/tests/errors/e_cdef_keywords_T241.pyx
+++ b/tests/errors/e_cdef_keywords_T241.pyx
@@ -1,4 +1,4 @@
-# ticket: 241
+# ticket: t241
# mode: error
cdef some_function(x, y):
diff --git a/tests/errors/e_cdefemptysue.pyx b/tests/errors/e_cdefemptysue.pyx
index f71370f4a..7f218b1fe 100644
--- a/tests/errors/e_cdefemptysue.pyx
+++ b/tests/errors/e_cdefemptysue.pyx
@@ -8,8 +8,21 @@ ctypedef union eggs:
cdef enum ham:
pass
+
+
+cdef struct flat_spam: pass
+
+ctypedef union flat_eggs: pass
+
+cdef enum flat_ham: pass
+
+
_ERRORS = u"""
3:5: Empty struct or union definition not allowed outside a 'cdef extern from' block
6:0: Empty struct or union definition not allowed outside a 'cdef extern from' block
9:5: Empty enum definition not allowed outside a 'cdef extern from' block
+
+13:5: Empty struct or union definition not allowed outside a 'cdef extern from' block
+15:0: Empty struct or union definition not allowed outside a 'cdef extern from' block
+17:5: Empty enum definition not allowed outside a 'cdef extern from' block
"""
diff --git a/tests/errors/e_cenum_with_type.pyx b/tests/errors/e_cenum_with_type.pyx
new file mode 100644
index 000000000..43c0e08fc
--- /dev/null
+++ b/tests/errors/e_cenum_with_type.pyx
@@ -0,0 +1,8 @@
+# mode: error
+
+cdef enum Spam(int):
+ a, b
+
+_ERRORS = u"""
+3:14: Expected ':', found '('
+"""
diff --git a/tests/errors/e_cpp_only_features.pyx b/tests/errors/e_cpp_only_features.pyx
index 005e415e6..19b7a6e39 100644
--- a/tests/errors/e_cpp_only_features.pyx
+++ b/tests/errors/e_cpp_only_features.pyx
@@ -21,6 +21,6 @@ def use_del():
_ERRORS = """
8:10: typeid operator only allowed in c++
8:23: typeid operator only allowed in c++
-14:20: Operation only allowed in c++
+14:16: Operation only allowed in c++
19:4: Operation only allowed in c++
"""
diff --git a/tests/errors/e_cpp_references.pyx b/tests/errors/e_cpp_references.pyx
new file mode 100644
index 000000000..39ace0a13
--- /dev/null
+++ b/tests/errors/e_cpp_references.pyx
@@ -0,0 +1,10 @@
+# mode: error
+# tag: cpp, cpp11
+
+cdef foo(object& x): pass
+cdef bar(object&& x): pass
+
+_ERRORS="""
+4:15: Reference base type cannot be a Python object
+5:15: Rvalue-reference base type cannot be a Python object
+"""
diff --git a/tests/errors/e_cstruct.pyx b/tests/errors/e_cstruct.pyx
index ad3ca9695..e0a09fbeb 100644
--- a/tests/errors/e_cstruct.pyx
+++ b/tests/errors/e_cstruct.pyx
@@ -24,7 +24,7 @@ cdef void eggs(Spam s):
_ERRORS = u"""
-7:39: C struct/union member cannot be a Python object
+7:4: C struct/union member cannot be a Python object
17:9: Object of type 'Spam' has no attribute 'k'
18:9: Cannot assign type 'float (*)[42]' to 'int'
19:10: Cannot assign type 'int' to 'float (*)[42]'
diff --git a/tests/errors/e_decorators.pyx b/tests/errors/e_decorators.pyx
deleted file mode 100644
index 5abc1fc29..000000000
--- a/tests/errors/e_decorators.pyx
+++ /dev/null
@@ -1,13 +0,0 @@
-# mode: error
-
-_ERRORS = u"""
-4:4 Expected a newline after decorator
-"""
-
-
-class A:
- pass
-
-@A().a
-def f():
- pass
diff --git a/tests/errors/e_excvalfunctype.pyx b/tests/errors/e_excvalfunctype.pyx
index a1d978322..25cae47c6 100644
--- a/tests/errors/e_excvalfunctype.pyx
+++ b/tests/errors/e_excvalfunctype.pyx
@@ -1,7 +1,7 @@
# mode: error
ctypedef int (*spamfunc)(int, char *) except 42
-ctypedef int (*grailfunc)(int, char *)
+ctypedef int (*grailfunc)(int, char *) noexcept
cdef grailfunc grail
cdef spamfunc spam
diff --git a/tests/errors/e_exttype_total_ordering.pyx b/tests/errors/e_exttype_total_ordering.pyx
new file mode 100644
index 000000000..6d5dd34e6
--- /dev/null
+++ b/tests/errors/e_exttype_total_ordering.pyx
@@ -0,0 +1,178 @@
+# mode: error
+# tag: total_ordering, warnings
+
+cimport cython
+
+
+# Test all combinations with not enough methods.
+
+@cython.total_ordering
+cdef class ExtNoFuncs:
+ pass
+
+@cython.total_ordering
+cdef class ExtGe:
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLe:
+ def __le__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLeGe:
+ def __le__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtGt:
+ def __gt__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtGtGe:
+ def __gt__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtGtLe:
+ def __gt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtGtLeGe:
+ def __gt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLt:
+ def __lt__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGe:
+ def __lt__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtLe:
+ def __lt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtLeGe:
+ def __lt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGt:
+ def __lt__(self, other):
+ return False
+
+ def __gt__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGtGe:
+ def __lt__(self, other):
+ return False
+
+ def __gt__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGtLe:
+ def __lt__(self, other):
+ return False
+
+ def __gt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtLtGtLeGe:
+ def __lt__(self, other):
+ return False
+
+ def __gt__(self, other):
+ return False
+
+ def __le__(self, other):
+ return False
+
+ def __ge__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtNe:
+ def __ne__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtEq:
+ def __eq__(self, other):
+ return False
+
+@cython.total_ordering
+cdef class ExtEqNe:
+ def __eq__(self, other):
+ return False
+
+ def __ne__(self, other):
+ return False
+
+
+_WARNINGS = """
+10:5: total_ordering directive used, but no comparison and equality methods defined
+14:5: total_ordering directive used, but no equality method defined
+19:5: total_ordering directive used, but no equality method defined
+24:5: total_ordering directive used, but no equality method defined
+32:5: total_ordering directive used, but no equality method defined
+37:5: total_ordering directive used, but no equality method defined
+45:5: total_ordering directive used, but no equality method defined
+53:5: total_ordering directive used, but no equality method defined
+64:5: total_ordering directive used, but no equality method defined
+69:5: total_ordering directive used, but no equality method defined
+77:5: total_ordering directive used, but no equality method defined
+85:5: total_ordering directive used, but no equality method defined
+96:5: total_ordering directive used, but no equality method defined
+104:5: total_ordering directive used, but no equality method defined
+115:5: total_ordering directive used, but no equality method defined
+126:5: total_ordering directive used, but no equality method defined
+140:5: total_ordering directive used, but no comparison methods defined
+145:5: total_ordering directive used, but no comparison methods defined
+150:5: total_ordering directive used, but no comparison methods defined
+"""
diff --git a/tests/errors/e_int_literals_py2.py b/tests/errors/e_int_literals_py2.py
index 9eef36673..750214e5e 100644
--- a/tests/errors/e_int_literals_py2.py
+++ b/tests/errors/e_int_literals_py2.py
@@ -3,7 +3,7 @@
def int_literals():
a = 1L # ok
- b = 10000000000000L # ok
+ b = 10000000000000L # ok
c = 1UL
d = 10000000000000UL
e = 10000000000000LL
diff --git a/tests/errors/e_invalid_special_cython_modules.py b/tests/errors/e_invalid_special_cython_modules.py
new file mode 100644
index 000000000..266b04686
--- /dev/null
+++ b/tests/errors/e_invalid_special_cython_modules.py
@@ -0,0 +1,46 @@
+# mode: error
+# tag: pure, import, cimport
+
+# nok
+
+import cython.imports.libc as libc_import
+import cython.cimports.labc as labc_cimport
+
+from cython.imports import libc
+from cython.cimport.libc import math
+from cython.imports.libc import math
+from cython.cimports.labc import math
+
+import cython.paralel
+import cython.parrallel
+
+import cython.dataclass
+import cython.floating
+import cython.cfunc
+
+# ok
+from cython.cimports.libc import math
+from cython.cimports.libc.math import ceil
+
+
+def libc_math_ceil(x):
+ """
+ >>> libc_math_ceil(1.5)
+ [2, 2]
+ """
+ return [int(n) for n in [ceil(x), math.ceil(x)]]
+
+
+_ERRORS = """
+6:7: 'cython.imports.libc' is not a valid cython.* module. Did you mean 'cython.cimports' ?
+7:7: 'labc.pxd' not found
+9:0: 'cython.imports' is not a valid cython.* module. Did you mean 'cython.cimports' ?
+10:0: 'cython.cimport.libc' is not a valid cython.* module. Did you mean 'cython.cimports' ?
+11:0: 'cython.imports.libc' is not a valid cython.* module. Did you mean 'cython.cimports' ?
+12:0: 'labc/math.pxd' not found
+14:7: 'cython.paralel' is not a valid cython.* module. Did you mean 'cython.parallel' ?
+15:7: 'cython.parrallel' is not a valid cython.* module. Did you mean 'cython.parallel' ?
+17:7: 'cython.dataclass' is not a valid cython.* module. Did you mean 'cython.dataclasses' ?
+18:7: 'cython.floating' is not a valid cython.* module. Instead, use 'import cython' and then 'cython.floating'.
+19:7: 'cython.cfunc' is not a valid cython.* module. Instead, use 'import cython' and then 'cython.cfunc'.
+"""
diff --git a/tests/errors/e_nogilfunctype.pyx b/tests/errors/e_nogilfunctype.pyx
index ccac37b7e..ac06af27e 100644
--- a/tests/errors/e_nogilfunctype.pyx
+++ b/tests/errors/e_nogilfunctype.pyx
@@ -10,7 +10,7 @@ fp = f
fp = <fp_t>f
_ERRORS = u"""
-9:5: Cannot assign type 'void (void)' to 'void (*)(void) nogil'
+9:5: Cannot assign type 'void (void) noexcept' to 'void (*)(void) noexcept nogil'
"""
_WARNINGS = """
diff --git a/tests/errors/e_public_cdef_private_types.pyx b/tests/errors/e_public_cdef_private_types.pyx
index 331d6c04f..9d8f55c87 100644
--- a/tests/errors/e_public_cdef_private_types.pyx
+++ b/tests/errors/e_public_cdef_private_types.pyx
@@ -38,6 +38,6 @@ e_public_cdef_private_types.pyx:8:22: Function declared public or api may not ha
e_public_cdef_private_types.pyx:11:19: Function declared public or api may not have private types
e_public_cdef_private_types.pyx:14:5: Function declared public or api may not have private types
e_public_cdef_private_types.pyx:17:5: Function declared public or api may not have private types
-e_public_cdef_private_types.pyx:20:25: Function with optional arguments may not be declared public or api
-e_public_cdef_private_types.pyx:23:22: Function with optional arguments may not be declared public or api
+e_public_cdef_private_types.pyx:20:24: Function with optional arguments may not be declared public or api
+e_public_cdef_private_types.pyx:23:21: Function with optional arguments may not be declared public or api
"""
diff --git a/tests/errors/e_pure_cimports.pyx b/tests/errors/e_pure_cimports.pyx
new file mode 100644
index 000000000..ef81182ad
--- /dev/null
+++ b/tests/errors/e_pure_cimports.pyx
@@ -0,0 +1,32 @@
+# mode: error
+# tag: pure, import, cimport
+
+import cython.cimportsy
+
+import cython.cimports
+import cython.cimports.libc
+import cython.cimports as cim
+
+cimport cython.cimports
+cimport cython.cimports.libc
+cimport cython.cimports as cim
+import cython.cimports.libc as cython
+
+
+# ok
+import cython.cimports.libc as libc
+from cython.cimports import libc
+from cython.cimports cimport libc
+
+
+_ERRORS = """
+4:7: 'cython.cimportsy' is not a valid cython.* module. Did you mean 'cython.cimports' ?
+6:7: Cannot cimport the 'cython.cimports' package directly, only submodules.
+7:7: Python cimports must use 'from cython.cimports... import ...' or 'import ... as ...', not just 'import ...'
+8:7: Cannot cimport the 'cython.cimports' package directly, only submodules.
+10:8: Cannot cimport the 'cython.cimports' package directly, only submodules.
+11:8: Python cimports must use 'from cython.cimports... import ...' or 'import ... as ...', not just 'import ...'
+12:8: Cannot cimport the 'cython.cimports' package directly, only submodules.
+# The following is not an accurate error message, but it's difficult to distinguish this case. And it's rare.
+13:7: Python cimports must use 'from cython.cimports... import ...' or 'import ... as ...', not just 'import ...'
+"""
diff --git a/tests/errors/e_relative_cimport.pyx b/tests/errors/e_relative_cimport.pyx
index 36a134411..709cbd71d 100644
--- a/tests/errors/e_relative_cimport.pyx
+++ b/tests/errors/e_relative_cimport.pyx
@@ -9,7 +9,7 @@ from . cimport e_relative_cimport
_ERRORS="""
4:0: relative cimport beyond main package is not allowed
-5:0: relative cimport beyond main package is not allowed
+5:0: relative cimport from non-package directory is not allowed
6:0: relative cimport beyond main package is not allowed
-7:0: relative cimport beyond main package is not allowed
+7:0: relative cimport from non-package directory is not allowed
"""
diff --git a/tests/errors/e_tuple_args_T692.py b/tests/errors/e_tuple_args_T692.py
index 715433d01..3ca30519b 100644
--- a/tests/errors/e_tuple_args_T692.py
+++ b/tests/errors/e_tuple_args_T692.py
@@ -1,4 +1,4 @@
-# ticket: 692
+# ticket: t692
# mode: error
def func((a, b)):
@@ -9,4 +9,3 @@ _ERRORS = u"""
5:11: undeclared name not builtin: a
5:15: undeclared name not builtin: b
"""
-
diff --git a/tests/errors/e_typing_errors.pyx b/tests/errors/e_typing_errors.pyx
new file mode 100644
index 000000000..832f68d90
--- /dev/null
+++ b/tests/errors/e_typing_errors.pyx
@@ -0,0 +1,59 @@
+# mode: error
+
+import cython
+
+try:
+ from typing import Optional, ClassVar
+except ImportError:
+ pass
+
+
+# not OK
+
+def optional_cython_types(Optional[cython.int] i, Optional[cython.double] d, Optional[cython.float] f,
+ Optional[cython.complex] c, Optional[cython.long] l, Optional[cython.longlong] ll):
+ pass
+
+
+MyStruct = cython.struct(a=cython.int, b=cython.double)
+
+def optional_cstruct(Optional[MyStruct] x):
+ pass
+
+
+def optional_pytypes(Optional[int] i, Optional[float] f, Optional[complex] c, Optional[long] l):
+ pass
+
+
+cdef ClassVar[list] x
+
+
+# OK
+
+def optional_memoryview(double[:] d, Optional[double[:]] o):
+ pass
+
+
+cdef class Cls(object):
+ cdef ClassVar[list] x
+
+
+
+_ERRORS = """
+13:42: typing.Optional[...] cannot be applied to non-Python type int
+13:66: typing.Optional[...] cannot be applied to non-Python type double
+13:93: typing.Optional[...] cannot be applied to non-Python type float
+14:42: typing.Optional[...] cannot be applied to non-Python type double complex
+14:70: typing.Optional[...] cannot be applied to non-Python type long
+14:95: typing.Optional[...] cannot be applied to non-Python type long long
+24:30: typing.Optional[...] cannot be applied to non-Python type int
+24:47: typing.Optional[...] cannot be applied to non-Python type float
+24:87: typing.Optional[...] cannot be applied to non-Python type long
+
+20:30: typing.Optional[...] cannot be applied to non-Python type MyStruct
+
+28:20: Modifier 'typing.ClassVar' is not allowed here.
+
+# FIXME: this should be ok :-?
+33:52: typing.Optional[...] cannot be applied to non-Python type double[:]
+"""
diff --git a/tests/errors/e_typing_optional.py b/tests/errors/e_typing_optional.py
new file mode 100644
index 000000000..6facfeea4
--- /dev/null
+++ b/tests/errors/e_typing_optional.py
@@ -0,0 +1,43 @@
+# mode: error
+
+import cython
+
+try:
+ from typing import Optional
+except ImportError:
+ pass
+
+
+# not OK
+
+def optional_cython_types(i: Optional[cython.int], d: Optional[cython.double], f: Optional[cython.float],
+ c: Optional[cython.complex], l: Optional[cython.long], ll: Optional[cython.longlong]):
+ pass
+
+
+MyStruct = cython.struct(a=cython.int, b=cython.double)
+
+def optional_cstruct(x: Optional[MyStruct]):
+ pass
+
+
+# OK
+
+def optional_pytypes(i: Optional[int], f: Optional[float], c: Optional[complex], l: Optional[long]):
+ pass
+
+
+def optional_memoryview(d: double[:], o: Optional[double[:]]):
+ pass
+
+
+_ERRORS = """
+13:44: typing.Optional[...] cannot be applied to non-Python type int
+13:69: typing.Optional[...] cannot be applied to non-Python type double
+13:97: typing.Optional[...] cannot be applied to non-Python type float
+14:44: typing.Optional[...] cannot be applied to non-Python type double complex
+14:73: typing.Optional[...] cannot be applied to non-Python type long
+14:100: typing.Optional[...] cannot be applied to non-Python type long long
+
+20:33: typing.Optional[...] cannot be applied to non-Python type MyStruct
+"""
diff --git a/tests/errors/fused_types.pyx b/tests/errors/fused_types.pyx
index 6d9dd6879..31aa35b86 100644
--- a/tests/errors/fused_types.pyx
+++ b/tests/errors/fused_types.pyx
@@ -49,6 +49,18 @@ def outer(cython.floating f):
def inner():
cdef cython.floating g
+
+# Mixing const and non-const type makes fused type ambiguous
+cdef fused mix_const_t:
+ int
+ const int
+
+cdef cdef_func_with_mix_const_type(mix_const_t val):
+ print(val)
+
+cdef_func_with_mix_const_type(1)
+
+
# This is all valid
dtype5 = fused_type(int, long, float)
dtype6 = cython.fused_type(int, long)
@@ -64,16 +76,15 @@ ctypedef fused fused2:
func(x, y)
+cdef floating return_type_unfindable1(cython.integral x):
+ return 1.0
-cdef fused mix_const_t:
- int
- const int
-
-cdef cdef_func_with_mix_const_type(mix_const_t val):
- print(val)
+cpdef floating return_type_unfindable2(cython.integral x):
+ return 1.0
-# Mixing const and non-const type makes fused type ambiguous
-cdef_func_with_mix_const_type(1)
+cdef void contents_unfindable1(cython.integral x):
+ z: floating = 1 # note: cdef variables also fail with an error but not by the time this test aborts
+ sz = sizeof(floating)
_ERRORS = u"""
@@ -88,7 +99,17 @@ _ERRORS = u"""
37:6: Invalid base type for memoryview slice: int *
40:0: Fused lambdas not allowed
43:5: Fused types not allowed here
+43:21: cdef variable 'x' declared after it is used
46:9: Fused types not allowed here
-76:0: Invalid use of fused types, type cannot be specialized
-76:29: ambiguous overloaded method
+61:0: Invalid use of fused types, type cannot be specialized
+61:29: ambiguous overloaded method
+# Possibly duplicates the errors more often than we want
+79:5: Return type is a fused type that cannot be determined from the function arguments
+82:6: Return type is a fused type that cannot be determined from the function arguments
+86:4: 'z' cannot be specialized since its type is not a fused argument to this function
+86:4: 'z' cannot be specialized since its type is not a fused argument to this function
+86:4: 'z' cannot be specialized since its type is not a fused argument to this function
+87:16: Type cannot be specialized since it is not a fused argument to this function
+87:16: Type cannot be specialized since it is not a fused argument to this function
+87:16: Type cannot be specialized since it is not a fused argument to this function
"""
diff --git a/tests/errors/incomplete_varadic.pyx b/tests/errors/incomplete_varadic.pyx
new file mode 100644
index 000000000..1695a874d
--- /dev/null
+++ b/tests/errors/incomplete_varadic.pyx
@@ -0,0 +1,8 @@
+# mode: error
+
+cdef error_time(bool its_fine, .):
+ pass
+
+_ERRORS = u"""
+3: 31: Expected an identifier, found '.'
+"""
diff --git a/tests/errors/missing_baseclass_in_predecl_T262.pyx b/tests/errors/missing_baseclass_in_predecl_T262.pyx
index ece07b155..907f072f5 100644
--- a/tests/errors/missing_baseclass_in_predecl_T262.pyx
+++ b/tests/errors/missing_baseclass_in_predecl_T262.pyx
@@ -1,4 +1,4 @@
-# ticket: 262
+# ticket: t262
# mode: error
cdef class Album
diff --git a/tests/errors/missing_self_in_cpdef_method_T156.pyx b/tests/errors/missing_self_in_cpdef_method_T156.pyx
index 21241a221..e8b0c5369 100644
--- a/tests/errors/missing_self_in_cpdef_method_T156.pyx
+++ b/tests/errors/missing_self_in_cpdef_method_T156.pyx
@@ -1,4 +1,4 @@
-# ticket: 156
+# ticket: t156
# mode: error
cdef class B:
diff --git a/tests/errors/missing_self_in_cpdef_method_T165.pyx b/tests/errors/missing_self_in_cpdef_method_T165.pyx
index 6a95922d5..89763cd2a 100644
--- a/tests/errors/missing_self_in_cpdef_method_T165.pyx
+++ b/tests/errors/missing_self_in_cpdef_method_T165.pyx
@@ -1,4 +1,4 @@
-# ticket: 165
+# ticket: t165
# mode: error
cdef class A:
diff --git a/tests/errors/nogil.pyx b/tests/errors/nogil.pyx
index 1d22f9d9b..1fa323b69 100644
--- a/tests/errors/nogil.pyx
+++ b/tests/errors/nogil.pyx
@@ -8,14 +8,14 @@ cdef void g(int x) nogil:
cdef object z
z = None
-cdef void h(int x) nogil:
+cdef void h(int x) nogil: # allowed
p()
cdef object p() nogil:
pass
-cdef void r() nogil:
- q()
+cdef void r() nogil: # allowed
+ q() # allowed
cdef object m():
cdef object x, y = 0, obj
@@ -23,11 +23,11 @@ cdef object m():
global fred
q()
with nogil:
- r()
+ r() # allowed to call plain C functions
q()
- i = 42
+ i = 42 # allowed with type inference
obj = None
- 17L
+ 17L # allowed
<object>7j
help
xxx = `"Hello"`
@@ -45,14 +45,14 @@ cdef object m():
{x, y}
obj and x
t(obj)
-# f(42) # Cython handles this internally
+ f(42)
x + obj
-obj
x = y = obj
x, y = y, x
obj[i] = x
obj.fred = x
- print obj
+ print obj # allowed!
del fred
return obj
raise obj # allowed!
@@ -90,8 +90,22 @@ def bare_pyvar_name(object x):
with nogil:
x
-# For m(), the important thing is that there are errors on all lines in the range 23-69
-# except these: 29, 34, 44, 56, 58, 60, 62-64
+cdef int fstrings(int x, object obj) except -1 nogil:
+ f"" # allowed
+ f"a" # allowed
+ f"a"f"b" # allowed
+ f"{x}"
+ f"{obj}"
+
+cdef void slice_array() nogil:
+ with gil:
+ b = [1, 2, 3, 4]
+ cdef int[4] a = b[:]
+
+cdef int[:] main() nogil:
+ cdef int[4] a = [1,2,3,4]
+ return a
+
_ERRORS = u"""
4:5: Function with Python return type cannot be declared nogil
@@ -105,14 +119,10 @@ _ERRORS = u"""
31:16: Constructing complex number not allowed without gil
33:8: Assignment of Python object not allowed without gil
33:14: Backquote expression not allowed without gil
-33:15: Operation not allowed without gil
34:15: Assignment of Python object not allowed without gil
-34:15: Operation not allowed without gil
34:15: Python import not allowed without gil
-35:8: Operation not allowed without gil
35:13: Python import not allowed without gil
35:25: Constructing Python list not allowed without gil
-35:25: Operation not allowed without gil
36:17: Iterating over Python object not allowed without gil
38:11: Discarding owned Python object not allowed without gil
38:11: Indexing Python object not allowed without gil
@@ -137,6 +147,7 @@ _ERRORS = u"""
46:12: Discarding owned Python object not allowed without gil
46:12: Truth-testing Python object not allowed without gil
47:10: Python type test not allowed without gil
+48:9: Discarding owned Python object not allowed without gil
49:10: Discarding owned Python object not allowed without gil
49:10: Operation not allowed without gil
50:8: Discarding owned Python object not allowed without gil
@@ -151,10 +162,10 @@ _ERRORS = u"""
53:11: Indexing Python object not allowed without gil
54:11: Accessing Python attribute not allowed without gil
54:11: Assignment of Python object not allowed without gil
-55:8: Constructing Python tuple not allowed without gil
-55:8: Python print statement not allowed without gil
+
56:8: Deleting Python object not allowed without gil
57:8: Returning Python object not allowed without gil
+
59:11: Truth-testing Python object not allowed without gil
61:14: Truth-testing Python object not allowed without gil
63:8: For-loop using object bounds or target not allowed without gil
@@ -162,4 +173,13 @@ _ERRORS = u"""
63:24: Coercion from Python not allowed without the GIL
65:8: Try-except statement not allowed without gil
86:8: For-loop using object bounds or target not allowed without gil
+
+97:4: Discarding owned Python object not allowed without gil
+97:6: String formatting not allowed without gil
+98:4: Discarding owned Python object not allowed without gil
+98:6: String formatting not allowed without gil
+
+103:21: Coercion from Python not allowed without the GIL
+103:21: Slicing Python object not allowed without gil
+107:11: Operation not allowed without gil
"""
diff --git a/tests/errors/nogil_conditional.pyx b/tests/errors/nogil_conditional.pyx
new file mode 100644
index 000000000..e800eb199
--- /dev/null
+++ b/tests/errors/nogil_conditional.pyx
@@ -0,0 +1,81 @@
+# cython: remove_unreachable=False
+# mode: error
+
+cdef int f_nogil(int x) nogil:
+ cdef int y
+ y = x + 10
+ return y
+
+
+def f_gil(x):
+ y = 0
+ y = x + 100
+ return y
+
+
+def illegal_gil_usage():
+ cdef int res = 0
+ with nogil(True):
+ res = f_gil(res)
+
+ with nogil(True):
+ res = f_gil(res)
+
+ with gil(False):
+ res = f_gil(res)
+
+ with nogil(False):
+ res = f_nogil(res)
+
+
+def foo(a):
+ return a < 10
+
+
+def non_constant_condition(int x) -> int:
+ cdef int res = x
+ with nogil(x < 10):
+ res = f_nogil(res)
+
+ with gil(foo(x)):
+ res = f_gil(res)
+
+
+ctypedef fused number_or_object:
+ float
+ object
+
+
+def fused_type(number_or_object x):
+ with nogil(number_or_object is object):
+ res = x + 1
+
+ # This should be fine
+ with nogil(number_or_object is float):
+ res = x + 1
+
+ return res
+
+
+_ERRORS = u"""
+19:14: Accessing Python global or builtin not allowed without gil
+19:19: Calling gil-requiring function not allowed without gil
+19:19: Coercion from Python not allowed without the GIL
+19:19: Constructing Python tuple not allowed without gil
+19:20: Converting to Python object not allowed without gil
+21:13: Trying to release the GIL while it was previously released.
+22:18: Accessing Python global or builtin not allowed without gil
+22:23: Calling gil-requiring function not allowed without gil
+22:23: Coercion from Python not allowed without the GIL
+22:23: Constructing Python tuple not allowed without gil
+22:24: Converting to Python object not allowed without gil
+25:18: Accessing Python global or builtin not allowed without gil
+25:23: Calling gil-requiring function not allowed without gil
+25:23: Coercion from Python not allowed without the GIL
+25:23: Constructing Python tuple not allowed without gil
+25:24: Converting to Python object not allowed without gil
+37:17: Non-constant condition in a `with nogil(<condition>)` statement
+40:16: Non-constant condition in a `with gil(<condition>)` statement
+51:8: Assignment of Python object not allowed without gil
+51:16: Calling gil-requiring function not allowed without gil
+"""
diff --git a/tests/errors/nogilfunctype.pyx b/tests/errors/nogilfunctype.pyx
index 91127bee4..c0ca2bb15 100644
--- a/tests/errors/nogilfunctype.pyx
+++ b/tests/errors/nogilfunctype.pyx
@@ -12,5 +12,5 @@ gp = g
fp = f
_ERRORS = u"""
-12:5: Cannot assign type 'void (void)' to 'void (*)(void) nogil'
+12:5: Cannot assign type 'void (void) noexcept' to 'void (*)(void) noexcept nogil'
"""
diff --git a/tests/errors/nonconst_excval.pyx b/tests/errors/nonconst_excval.pyx
new file mode 100644
index 000000000..ad80f2e27
--- /dev/null
+++ b/tests/errors/nonconst_excval.pyx
@@ -0,0 +1,12 @@
+# mode: error
+
+import math
+
+cdef double cfunc(double x) except math.nan:
+ return x
+
+
+_ERRORS = """
+5:39: Exception value must be constant
+5:39: Not allowed in a constant expression
+"""
diff --git a/tests/errors/notcimportedT418.pyx b/tests/errors/notcimportedT418.pyx
index 980d66555..c2821fb83 100644
--- a/tests/errors/notcimportedT418.pyx
+++ b/tests/errors/notcimportedT418.pyx
@@ -1,4 +1,4 @@
-# ticket: 418
+# ticket: t418
# mode: error
import somemod.child
diff --git a/tests/errors/pep487_exttype.pyx b/tests/errors/pep487_exttype.pyx
new file mode 100644
index 000000000..e9e4f44a2
--- /dev/null
+++ b/tests/errors/pep487_exttype.pyx
@@ -0,0 +1,13 @@
+# mode: error
+
+cdef class Imp:
+ def __init_subclass__(cls, a=None, **kwargs):
+ super().__init_subclass__(**kwargs)
+ print(a)
+
+cdef class ExImp1(Imp): pass
+class ExImp2(Imp, a=60): pass
+
+_ERRORS = u"""
+4:4: '__init_subclass__' is not supported by extension class
+"""
diff --git a/tests/errors/pep492_badsyntax_async2.pyx b/tests/errors/pep492_badsyntax_async2.pyx
deleted file mode 100644
index 4ea30dba1..000000000
--- a/tests/errors/pep492_badsyntax_async2.pyx
+++ /dev/null
@@ -1,11 +0,0 @@
-# mode: error
-# tag: pep492, async
-
-async def foo():
- def foo(a:await list()):
- pass
-
-_ERRORS = """
-5:14: 'await' not supported here
-5:14: 'await' not supported here
-"""
diff --git a/tests/errors/posonly.pyx b/tests/errors/posonly.pyx
new file mode 100644
index 000000000..2724f3037
--- /dev/null
+++ b/tests/errors/posonly.pyx
@@ -0,0 +1,102 @@
+# mode: error
+# tag: posonly
+
+def f(a, b = 5, /, c):
+ pass
+
+def f(a = 5, b, /, c):
+ pass
+
+def f(a = 5, b, /):
+ pass
+
+def f(a, /, a):
+ pass
+
+def f(a, /, *, a):
+ pass
+
+#def f(a, b/2, c): #D
+# pass
+
+#def f(*args, /): #D
+# pass
+
+#def f(*args, a, /):
+# pass
+
+#def f(**kwargs, /):
+# pass
+
+#def f(/, a = 1): # D
+# pass
+
+#def f(/, a):
+# pass
+
+#def f(/):
+# pass
+
+#def f(*, a, /):
+# pass
+
+#def f(*, /, a):
+# pass
+
+#def f(a, /, c, /):
+# pass
+
+#def f(a, /, c, /, d):
+# pass
+
+#def f(a, /, c, /, d, *, e):
+# pass
+
+#def f(a, *, c, /, d, e):
+# pass
+
+def test_invalid_syntax_lambda(self):
+ lambda a, b = 5, /, c: None
+ lambda a = 5, b, /, c: None
+ lambda a = 5, b, /: None
+ lambda a, /, a: None
+ lambda a, /, *, a: None
+# lambda *args, /: None
+# lambda *args, a, /: None
+# lambda **kwargs, /: None
+# lambda /, a = 1: None
+# lambda /, a: None
+# lambda /: None
+# lambda *, a, /: None
+# lambda *, /, a: None
+
+async def f(a, b = 5, /, c):
+ pass
+
+#def test_multiple_seps(a,/,b,/):
+# pass
+
+_ERRORS = u"""
+4:19: Non-default argument following default argument
+7:13: Non-default argument following default argument
+7:19: Non-default argument following default argument
+10:13: Non-default argument following default argument
+13:6: Previous declaration is here
+13:12: 'a' redeclared
+16:6: Previous declaration is here
+16:15: 'a' redeclared
+59:24: Non-default argument following default argument
+60:18: Non-default argument following default argument
+60:24: Non-default argument following default argument
+61:18: Non-default argument following default argument
+62:11: Previous declaration is here
+62:17: 'a' redeclared
+63:11: Previous declaration is here
+63:20: 'a' redeclared
+73:25: Non-default argument following default argument
+"""
+
+
+
+
+
diff --git a/tests/errors/posonly2.pyx b/tests/errors/posonly2.pyx
new file mode 100644
index 000000000..dab079047
--- /dev/null
+++ b/tests/errors/posonly2.pyx
@@ -0,0 +1,9 @@
+# mode: error
+# tag: posonly
+
+def f(a, b/2, c):
+ pass
+
+_ERRORS = u"""
+4:11: Syntax error in Python function argument list
+"""
diff --git a/tests/errors/posonly3.pyx b/tests/errors/posonly3.pyx
new file mode 100644
index 000000000..4b4f0db75
--- /dev/null
+++ b/tests/errors/posonly3.pyx
@@ -0,0 +1,13 @@
+# mode: error
+# tag: posonly
+
+def f(*args, /):
+ pass
+
+def f(*args, a, /):
+ pass
+
+
+_ERRORS = u"""
+4:13: Expected ')', found '/'
+"""
diff --git a/tests/errors/posonly4.pyx b/tests/errors/posonly4.pyx
new file mode 100644
index 000000000..d1a1f61f9
--- /dev/null
+++ b/tests/errors/posonly4.pyx
@@ -0,0 +1,9 @@
+# mode: error
+# tag: posonly
+
+def f(/, a = 1):
+ pass
+
+_ERRORS = u"""
+4:6: Got zero positional-only arguments despite presence of positional-only specifier '/'
+"""
diff --git a/tests/errors/posonly5.pyx b/tests/errors/posonly5.pyx
new file mode 100644
index 000000000..9e359226a
--- /dev/null
+++ b/tests/errors/posonly5.pyx
@@ -0,0 +1,11 @@
+# mode: error
+# tag: posonly
+
+def test_multiple_seps(a,/,b,/):
+ pass
+
+_ERRORS = u"""
+4:29: Expected ')', found '/'
+"""
+
+
diff --git a/tests/errors/pure_errors.py b/tests/errors/pure_errors.py
index 4a9dca53b..e348abbae 100644
--- a/tests/errors/pure_errors.py
+++ b/tests/errors/pure_errors.py
@@ -50,8 +50,43 @@ def pyfunc(x): # invalid
return x + 1
+@cython.exceptval(-1)
+@cython.cfunc
+def test_cdef_return_object_broken(x: object) -> object:
+ return x
+
+
+@cython.ccall
+@cython.cfunc
+def test_contradicting_decorators1(x: object) -> object:
+ return x
+
+
+@cython.cfunc
+@cython.ccall
+def test_contradicting_decorators2(x: object) -> object:
+ return x
+
+
+@cython.cfunc
+@cython.ufunc
+def add_one(x: cython.double) -> cython.double:
+ return x+1
+
+
_ERRORS = """
44:22: Calling gil-requiring function not allowed without gil
45:24: Calling gil-requiring function not allowed without gil
-49:0: Python functions cannot be declared 'nogil'
+48:0: Python functions cannot be declared 'nogil'
+53:0: Exception clause not allowed for function returning Python object
+59:0: cfunc and ccall directives cannot be combined
+65:0: cfunc and ccall directives cannot be combined
+71:0: Cannot apply @cfunc to @ufunc, please reverse the decorators.
+"""
+
+_WARNINGS = """
+30:0: Directive does not change previous value (nogil=False)
+# bugs:
+59:0: 'test_contradicting_decorators1' redeclared
+65:0: 'test_contradicting_decorators2' redeclared
"""
diff --git a/tests/errors/pure_warnings.py b/tests/errors/pure_warnings.py
new file mode 100644
index 000000000..3109439cb
--- /dev/null
+++ b/tests/errors/pure_warnings.py
@@ -0,0 +1,63 @@
+# mode: error
+# tag: warnings
+
+import cython
+import typing
+from cython.cimports.libc import stdint
+
+
+def main():
+ foo1: typing.Tuple = None
+ foo1: typing.Bar = None
+ foo2: Bar = 1 # warning
+ foo3: int = 1
+ foo4: cython.int = 1
+ foo5: stdint.bar = 5 # warning
+ foo6: object = 1
+ foo7: cython.bar = 1 # error
+ foo8: (1 + x).b
+ foo9: mod.a.b
+ foo10: func().b
+ with cython.annotation_typing(False):
+ foo8: Bar = 1
+ foo9: stdint.bar = 5
+ foo10: cython.bar = 1
+
+
+@cython.cfunc
+def bar() -> cython.bar:
+ pass
+
+
+@cython.cfunc
+def bar2() -> Bar:
+ pass
+
+@cython.cfunc
+def bar3() -> stdint.bar:
+ pass
+
+_WARNINGS = """
+12:10: Unknown type declaration 'Bar' in annotation, ignoring
+15:16: Unknown type declaration 'stdint.bar' in annotation, ignoring
+18:17: Unknown type declaration in annotation, ignoring
+19:15: Unknown type declaration in annotation, ignoring
+20:17: Unknown type declaration in annotation, ignoring
+33:14: Unknown type declaration 'Bar' in annotation, ignoring
+37:20: Unknown type declaration 'stdint.bar' in annotation, ignoring
+
+# Spurious warnings from utility code - not part of the core test
+25:10: 'cpdef_method' redeclared
+36:10: 'cpdef_cname_method' redeclared
+980:29: Ambiguous exception value, same as default return value: 0
+1021:46: Ambiguous exception value, same as default return value: 0
+1111:29: Ambiguous exception value, same as default return value: 0
+"""
+
+_ERRORS = """
+17:16: Unknown type declaration 'cython.bar' in annotation
+28:13: Not a type
+28:19: Unknown type declaration 'cython.bar' in annotation
+33:14: Not a type
+37:14: Not a type
+"""
diff --git a/tests/errors/pxd_cdef_class_declaration_T286.pyx b/tests/errors/pxd_cdef_class_declaration_T286.pyx
index 0c968f701..b1a8bc844 100644
--- a/tests/errors/pxd_cdef_class_declaration_T286.pyx
+++ b/tests/errors/pxd_cdef_class_declaration_T286.pyx
@@ -1,4 +1,4 @@
-# ticket: 286
+# ticket: t286
# mode: error
cdef class A:
diff --git a/tests/errors/pyobjcastdisallow_T313.pyx b/tests/errors/pyobjcastdisallow_T313.pyx
index 5048719d8..30973380f 100644
--- a/tests/errors/pyobjcastdisallow_T313.pyx
+++ b/tests/errors/pyobjcastdisallow_T313.pyx
@@ -1,4 +1,4 @@
-# ticket: 313
+# ticket: t313
# mode: error
a = 3
diff --git a/tests/errors/redeclaration_of_var_by_cfunc_T600.pyx b/tests/errors/redeclaration_of_var_by_cfunc_T600.pyx
new file mode 100644
index 000000000..a568f0f90
--- /dev/null
+++ b/tests/errors/redeclaration_of_var_by_cfunc_T600.pyx
@@ -0,0 +1,14 @@
+# ticket: 600
+# mode: error
+
+cdef class Bar:
+ cdef list _operands
+
+ cdef int _operands(self):
+ return -1
+
+
+_ERRORS = """
+7:9: '_operands' redeclared
+5:14: Previous declaration is here
+"""
diff --git a/tests/errors/return_outside_function_T135.pyx b/tests/errors/return_outside_function_T135.pyx
index d7432ca50..4788c2a72 100644
--- a/tests/errors/return_outside_function_T135.pyx
+++ b/tests/errors/return_outside_function_T135.pyx
@@ -1,5 +1,5 @@
# cython: remove_unreachable=False
-# ticket: 135
+# ticket: t135
# mode: error
def _runtime_True():
diff --git a/tests/errors/reversed_literal_pyobjs.pyx b/tests/errors/reversed_literal_pyobjs.pyx
index 8444eaf2b..e5d1cb97d 100644
--- a/tests/errors/reversed_literal_pyobjs.pyx
+++ b/tests/errors/reversed_literal_pyobjs.pyx
@@ -10,6 +10,7 @@ for i in reversed(range(j, [], 2)):
pass
for i in reversed(range(j, [], -2)):
pass
+# code below is no longer a compile-time error (although won't run without an exception)
for i in reversed(range({}, j, 2)):
pass
for i in reversed(range({}, j, -2)):
@@ -24,8 +25,4 @@ _ERRORS = """
7:24: Cannot coerce list to type 'long'
9:27: Cannot coerce list to type 'long'
11:27: Cannot coerce list to type 'long'
-13:24: Cannot interpret dict as type 'long'
-15:24: Cannot interpret dict as type 'long'
-17:27: Cannot interpret dict as type 'long'
-19:27: Cannot interpret dict as type 'long'
"""
diff --git a/tests/errors/tree_assert.pyx b/tests/errors/tree_assert.pyx
index 81ae9a1d3..09e54c67b 100644
--- a/tests/errors/tree_assert.pyx
+++ b/tests/errors/tree_assert.pyx
@@ -11,8 +11,8 @@ def test():
_ERRORS = u"""
-9:0: Expected path '//ComprehensionNode' not found in result tree
-9:0: Expected path '//ComprehensionNode//FuncDefNode' not found in result tree
-9:0: Unexpected path '//NameNode' found in result tree
-9:0: Unexpected path '//SimpleCallNode' found in result tree
+5:0: Expected path '//ComprehensionNode' not found in result tree
+5:0: Expected path '//ComprehensionNode//FuncDefNode' not found in result tree
+10:4: Unexpected path '//NameNode' found in result tree
+10:10: Unexpected path '//SimpleCallNode' found in result tree
"""
diff --git a/tests/errors/typoT304.pyx b/tests/errors/typoT304.pyx
index 7c736c898..2de5573d4 100644
--- a/tests/errors/typoT304.pyx
+++ b/tests/errors/typoT304.pyx
@@ -1,4 +1,4 @@
-# ticket: 304
+# ticket: t304
# mode: error
def f():
diff --git a/tests/errors/unicode_identifiers_e1.pyx b/tests/errors/unicode_identifiers_e1.pyx
new file mode 100644
index 000000000..5087a3d43
--- /dev/null
+++ b/tests/errors/unicode_identifiers_e1.pyx
@@ -0,0 +1,8 @@
+# -*- coding: utf-8 -*-
+# mode: error
+
+★1 = 5 # invalid start symbol
+
+_ERRORS = u"""
+4:0: Unrecognized character
+"""
diff --git a/tests/errors/unicode_identifiers_e2.pyx b/tests/errors/unicode_identifiers_e2.pyx
new file mode 100644
index 000000000..e9e53aa5b
--- /dev/null
+++ b/tests/errors/unicode_identifiers_e2.pyx
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+# mode: error
+
+class MyClass₡: # invalid continue symbol
+ pass
+
+_ERRORS = u"""
+4:13: Unrecognized character
+"""
diff --git a/tests/errors/unicode_identifiers_e3.pyx b/tests/errors/unicode_identifiers_e3.pyx
new file mode 100644
index 000000000..e5cba9caa
--- /dev/null
+++ b/tests/errors/unicode_identifiers_e3.pyx
@@ -0,0 +1,11 @@
+# -*- coding: utf-8 -*-
+# mode: error
+
+def f():
+ a = 1
+ ́b = 2 # looks like an indentation error but is actually a combining accent as the first letter of column 4
+ c = 3
+
+_ERRORS = u"""
+6:4: Unrecognized character
+"""
diff --git a/tests/errors/unicode_identifiers_e4.pyx b/tests/errors/unicode_identifiers_e4.pyx
new file mode 100644
index 000000000..035eff2c9
--- /dev/null
+++ b/tests/errors/unicode_identifiers_e4.pyx
@@ -0,0 +1,13 @@
+# -*- coding: utf-8 -*-
+# mode: error
+
+cdef class C:
+ # these two symbols "\u1e69" and "\u1e9b\u0323" normalize to the same thing
+ # so the two attributes can't coexist
+ cdef int ṩomething
+ cdef double ẛ̣omething
+
+_ERRORS = u"""
+7:13: Previous declaration is here
+8:16: 'ṩomething' redeclared
+"""
diff --git a/tests/errors/uninitialized_lhs.pyx b/tests/errors/uninitialized_lhs.pyx
index 5d5ece854..8550761a4 100644
--- a/tests/errors/uninitialized_lhs.pyx
+++ b/tests/errors/uninitialized_lhs.pyx
@@ -1,7 +1,7 @@
# cython: warn.maybe_uninitialized=True
# mode: error
# tag: werror
-# ticket: 739
+# ticket: t739
def index_lhs(a):
cdef object idx
diff --git a/tests/errors/w_numpy_arr_as_cppvec_ref.pyx b/tests/errors/w_numpy_arr_as_cppvec_ref.pyx
index e7fbaeece..d3a70dbed 100644
--- a/tests/errors/w_numpy_arr_as_cppvec_ref.pyx
+++ b/tests/errors/w_numpy_arr_as_cppvec_ref.pyx
@@ -1,10 +1,12 @@
# mode: error
-# tag: cpp, werror, numpy
+# tag: cpp, werror, numpy, no-cpp-locals
import numpy as np
cimport numpy as np
from libcpp.vector cimport vector
+np.import_array()
+
cdef extern from *:
void cpp_function_vector1(vector[int])
void cpp_function_vector2(vector[int] &)
@@ -24,8 +26,8 @@ def main():
_ERRORS = """
-17:25: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
-18:25: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
-19:28: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
-19:33: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
+19:25: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
+20:25: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
+21:28: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
+21:33: Cannot pass Python object as C++ data structure reference (vector[int] &), will pass by copy.
"""
diff --git a/tests/errors/w_uninitialized.pyx b/tests/errors/w_uninitialized.pyx
index c2046ce19..066f9ed5b 100644
--- a/tests/errors/w_uninitialized.pyx
+++ b/tests/errors/w_uninitialized.pyx
@@ -127,10 +127,10 @@ _ERRORS = """
66:10: local variable 'foo' referenced before assignment
71:14: local variable 'exc' referenced before assignment
71:19: local variable 'msg' referenced before assignment
-78:4: local variable 'decorator' referenced before assignment
+78:5: local variable 'decorator' referenced before assignment
85:16: local variable 'default' referenced before assignment
91:14: local variable 'bar' referenced before assignment
-97:4: local variable 'decorator' referenced before assignment
+97:5: local variable 'decorator' referenced before assignment
104:24: local variable 'Meta' referenced before assignment
110:15: local variable 'args' referenced before assignment
110:23: local variable 'kwargs' referenced before assignment