Commit cdd7a878 authored by Stefan Behnel's avatar Stefan Behnel

safer way to check for builtins in Optimize.py

parent 43bdaf62
...@@ -1110,8 +1110,9 @@ class EarlyReplaceBuiltinCalls(Visitor.EnvTransform): ...@@ -1110,8 +1110,9 @@ class EarlyReplaceBuiltinCalls(Visitor.EnvTransform):
def _function_is_builtin_name(self, function): def _function_is_builtin_name(self, function):
if not function.is_name: if not function.is_name:
return False return False
entry = self.current_env().lookup(function.name) env = self.current_env()
if entry and getattr(entry, 'scope', None) is not Builtin.builtin_scope: entry = env.lookup(function.name)
if entry is not env.builtin_scope().lookup_here(function.name):
return False return False
# if entry is None, it's at least an undeclared name, so likely builtin # if entry is None, it's at least an undeclared name, so likely builtin
return True return True
...@@ -1724,8 +1725,8 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform): ...@@ -1724,8 +1725,8 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
# into a C function call (defined in the builtin scope) # into a C function call (defined in the builtin scope)
if not function.entry: if not function.entry:
return node return node
is_builtin = function.entry.is_builtin \ is_builtin = function.entry.is_builtin or \
or getattr(function.entry, 'scope', None) is Builtin.builtin_scope function.entry is self.current_env().builtin_scope().lookup_here(function.name)
if not is_builtin: if not is_builtin:
return node return node
function_handler = self._find_handler( function_handler = self._find_handler(
......
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