Commit 875584d1 authored by da-woods's avatar da-woods Committed by GitHub

Error message on cpdef variables (GH-3963)

Allowing these gives people the false impression that they do something meaningful.

Closes https://github.com/cython/cython/issues/887
Closes https://github.com/cython/cython/issues/3959
parent fd8e8cbe
...@@ -1430,8 +1430,7 @@ class CVarDefNode(StatNode): ...@@ -1430,8 +1430,7 @@ class CVarDefNode(StatNode):
self.entry.create_wrapper = True self.entry.create_wrapper = True
else: else:
if self.overridable: if self.overridable:
warning(self.pos, "cpdef variables will not be supported in Cython 3; " error(self.pos, "Variables cannot be declared with 'cpdef'. Use 'cdef' instead.")
"currently they are no different from cdef variables", 2)
if self.directive_locals: if self.directive_locals:
error(self.pos, "Decorators can only be followed by functions") error(self.pos, "Decorators can only be followed by functions")
self.entry = dest_scope.declare_var( self.entry = dest_scope.declare_var(
......
# tag: warnings # mode: error
cpdef str a = "123" cpdef str a = "123"
cpdef b = 2 cpdef b = 2
...@@ -16,9 +16,9 @@ def func(): ...@@ -16,9 +16,9 @@ def func():
return d return d
_WARNINGS = """ _ERRORS = """
3:6: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables 3:6: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
4:6: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables 4:6: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
7:10: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables 7:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
15:10: cpdef variables will not be supported in Cython 3; currently they are no different from cdef variables 15:10: Variables cannot be declared with 'cpdef'. Use 'cdef' instead.
""" """
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