Commit b137e585 authored by Robert Bradshaw's avatar Robert Bradshaw

better error when user-declared type conflicts with builtin type (#170)

parent 5dbb42b3
...@@ -340,10 +340,14 @@ def init_builtin_funcs(): ...@@ -340,10 +340,14 @@ def init_builtin_funcs():
for desc in builtin_function_table: for desc in builtin_function_table:
declare_builtin_func(*desc) declare_builtin_func(*desc)
builtin_types = {}
def init_builtin_types(): def init_builtin_types():
global builtin_types
for name, cname, funcs in builtin_types_table: for name, cname, funcs in builtin_types_table:
utility = builtin_utility_code.get(name) utility = builtin_utility_code.get(name)
the_type = builtin_scope.declare_builtin_type(name, cname, utility) the_type = builtin_scope.declare_builtin_type(name, cname, utility)
builtin_types[name] = the_type
for name, args, ret, cname in funcs: for name, args, ret, cname in funcs:
sig = Signature(args, ret) sig = Signature(args, ret)
the_type.scope.declare_cfunction(name, sig.function_type(), None, cname) the_type.scope.declare_cfunction(name, sig.function_type(), None, cname)
......
...@@ -2676,6 +2676,12 @@ class CClassDefNode(ClassDefNode): ...@@ -2676,6 +2676,12 @@ class CClassDefNode(ClassDefNode):
return return
else: else:
home_scope = env home_scope = env
if self.visibility == 'extern':
if self.module_name == '__builtin__' and self.class_name in Builtin.builtin_types:
error(self.pos, "%s already a builtin Cython type" % self.class_name)
return
self.entry = home_scope.declare_c_class( self.entry = home_scope.declare_c_class(
name = self.class_name, name = self.class_name,
pos = self.pos, pos = self.pos,
......
cdef extern from *:
ctypedef class __builtin__.list [object PyListObject]:
pass
cdef list foo = []
_ERRORS = u"""
:2:4: list already a builtin Cython type
"""
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