Commit 34aa95a4 authored by Robert Bradshaw's avatar Robert Bradshaw

Real fix for builtins caching + coercion bug (as reported by paul.metcalfe@gmail.com)

parent 0cd67521
...@@ -773,6 +773,8 @@ class NameNode(AtomicExprNode): ...@@ -773,6 +773,8 @@ class NameNode(AtomicExprNode):
if entry and entry.is_cfunction: if entry and entry.is_cfunction:
var_entry = entry.as_variable var_entry = entry.as_variable
if var_entry: if var_entry:
if var_entry.is_builtin and Options.cache_builtins:
var_entry = env.declare_builtin(var_entry.name, self.pos)
node = NameNode(self.pos, name = self.name) node = NameNode(self.pos, name = self.name)
node.entry = var_entry node.entry = var_entry
node.analyse_rvalue_entry(env) node.analyse_rvalue_entry(env)
......
...@@ -717,10 +717,15 @@ class ModuleScope(Scope): ...@@ -717,10 +717,15 @@ class ModuleScope(Scope):
return self.outer_scope.declare_builtin(name, pos) return self.outer_scope.declare_builtin(name, pos)
else: else:
error(pos, "undeclared name not builtin: %s"%name) error(pos, "undeclared name not builtin: %s"%name)
entry = self.declare(name, name, py_object_type, pos) if Options.cache_builtins:
for entry in self.cached_builtins:
if entry.name == name:
return entry
entry = self.declare(None, None, py_object_type, pos)
if Options.cache_builtins: if Options.cache_builtins:
entry.is_builtin = 1 entry.is_builtin = 1
entry.is_const = 1 entry.is_const = 1
entry.name = name
entry.cname = Naming.builtin_prefix + name entry.cname = Naming.builtin_prefix + name
self.cached_builtins.append(entry) self.cached_builtins.append(entry)
self.undeclared_cached_builtins.append(entry) self.undeclared_cached_builtins.append(entry)
......
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