def declare_var(self, name, type, pos,
cname = None, visibility = 'private', is_cdef = True):
+ if type is unspecified_type:
+ # if the outer scope defines a type for this variable, inherit it
+ outer_entry = self.outer_scope.lookup(name)
+ if outer_entry and not outer_entry.is_builtin:
+ type = outer_entry.type # may still be 'unspecified_type' !
# the outer scope needs to generate code for the variable, but
# this scope must hold its name exclusively
cname = '%s%s' % (self.genexp_prefix, self.outer_scope.mangle(Naming.var_prefix, name))
return all(uchar.islower() for uchar in ustring)
@cython.test_assert_path_exists("//ForInStatNode",
- "//InlinedGeneratorExpressionNode")
+ "//InlinedGeneratorExpressionNode",
+ "//InlinedGeneratorExpressionNode//IfStatNode")
@cython.test_fail_if_path_exists("//SimpleCallNode",
- "//YieldExprNode")
+ "//YieldExprNode",
+ "//IfStatNode//CoerceToBooleanNode")
def all_in_typed_gen(seq):
"""
>>> all_in_typed_gen([1,1,1])
4
False
"""
- # FIXME: this isn't really supposed to work, but it currently does
- # due to incorrect scoping - this should be fixed!!
cdef int x
return all(x for x in seq)
@cython.test_assert_path_exists("//ForInStatNode",
- "//InlinedGeneratorExpressionNode")
+ "//InlinedGeneratorExpressionNode",
+ "//InlinedGeneratorExpressionNode//IfStatNode")
@cython.test_fail_if_path_exists("//SimpleCallNode",
- "//YieldExprNode")
+ "//YieldExprNode",
+ "//IfStatNode//CoerceToBooleanNode")
def all_in_nested_gen(seq):
"""
>>> all(x for L in [[1,1,1],[1,1,1],[1,1,1]] for x in L)
2
False
"""
- # FIXME: this isn't really supposed to work, but it currently does
- # due to incorrect scoping - this should be fixed!!
cdef int x
return all(x for L in seq for x in L)
upper_ustring = mixed_ustring.upper()
@cython.test_assert_path_exists('//PythonCapiCallNode',
- '//ForFromStatNode')
+ '//ForFromStatNode',
+ "//InlinedGeneratorExpressionNode")
@cython.test_fail_if_path_exists('//SimpleCallNode',
'//ForInStatNode')
def any_lower_case_characters(unicode ustring):
return any(uchar.islower() for uchar in ustring)
@cython.test_assert_path_exists("//ForInStatNode",
- "//InlinedGeneratorExpressionNode")
+ "//InlinedGeneratorExpressionNode",
+ "//InlinedGeneratorExpressionNode//IfStatNode")
@cython.test_fail_if_path_exists("//SimpleCallNode",
- "//YieldExprNode")
+ "//YieldExprNode",
+ "//IfStatNode//CoerceToBooleanNode")
def any_in_typed_gen(seq):
"""
>>> any_in_typed_gen([0,1,0])
5
False
"""
- # FIXME: this isn't really supposed to work, but it currently does
- # due to incorrect scoping - this should be fixed!!
cdef int x
return any(x for x in seq)
@cython.test_assert_path_exists("//ForInStatNode",
- "//InlinedGeneratorExpressionNode")
+ "//InlinedGeneratorExpressionNode",
+ "//InlinedGeneratorExpressionNode//IfStatNode")
@cython.test_fail_if_path_exists("//SimpleCallNode",
- "//YieldExprNode")
+ "//YieldExprNode",
+ "//IfStatNode//CoerceToBooleanNode")
def any_in_nested_gen(seq):
"""
>>> any(x for L in [[0,0,0],[0,0,1],[0,0,0]] for x in L)
3
False
"""
- # FIXME: this isn't really supposed to work, but it currently does
- # due to incorrect scoping - this should be fixed!!
cdef int x
return any(x for L in seq for x in L)