Commit 2a360337 authored by Robert Bradshaw's avatar Robert Bradshaw

Ensure scopes of var_entries are recorded.

This fixes #1540.
parent 905a14ba
......@@ -6376,7 +6376,8 @@ class AttributeNode(ExprNode):
# as an ordinary function.
if entry.func_cname and not hasattr(entry.type, 'op_arg_struct'):
cname = entry.func_cname
if entry.type.is_static_method or env.parent_scope.is_cpp_class_scope:
if entry.type.is_static_method or (
env.parent_scope and env.parent_scope.is_cpp_class_scope):
ctype = entry.type
elif type.is_cpp_class:
error(self.pos, "%s not a static member of %s" % (entry.name, type))
......@@ -6393,6 +6394,7 @@ class AttributeNode(ExprNode):
ubcm_entry.is_cfunction = 1
ubcm_entry.func_cname = entry.func_cname
ubcm_entry.is_unbound_cmethod = 1
ubcm_entry.scope = entry.scope
return self.as_name_node(env, ubcm_entry, target=False)
elif type.is_enum:
if self.attribute in type.values:
......
......@@ -981,6 +981,7 @@ class BuiltinScope(Scope):
var_entry.is_readonly = 1
var_entry.is_builtin = 1
var_entry.utility_code = utility_code
var_entry.scope = self
if Options.cache_builtins:
var_entry.is_const = True
entry.as_variable = var_entry
......@@ -1580,6 +1581,7 @@ class ModuleScope(Scope):
var_entry.is_variable = 1
var_entry.is_cglobal = 1
var_entry.is_readonly = 1
var_entry.scope = entry.scope
entry.as_variable = var_entry
def is_cpp(self):
......@@ -2122,6 +2124,7 @@ class CClassScope(ClassScope):
var_entry.is_variable = 1
var_entry.is_builtin = 1
var_entry.utility_code = utility_code
var_entry.scope = entry.scope
entry.as_variable = var_entry
return entry
......
......@@ -59,6 +59,13 @@ def call_static_cdef2(int x, int y):
"""
return A.static_cdef2(&x, &y)
def call_static_list_comprehension_GH1540(int x):
"""
>>> call_static_list_comprehension_GH1540(5)
[('cdef', 5), ('cdef', 5), ('cdef', 5)]
"""
return [A.static_cdef(&x) for _ in range(3)]
# BROKEN
#def call_static_cdef_untyped(a, b):
# """
......@@ -67,6 +74,7 @@ def call_static_cdef2(int x, int y):
# """
# return A.static_cdef_untyped(a, b)
# UNIMPLEMENTED
# def call_static_cpdef(int x):
# """
# >>> call_static_cpdef(2)
......
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