Export to GitHub

spitfire - issue #6

With -Xcheetah-cheats, placeholder resolution does not search locals()


Posted on Jan 27, 2010 by Swift Kangaroo

Source code:

set $a = 'foo'

set $b = $a

Compiling with -Xcheetah-cheats (no optimization) produces:

_self_search_list = self.search_list + [_globals]
_buffer_write(u'\n')
a = u'foo'
b = resolve_placeholder(_self_search_list, 'a')

This always fails during runtime with: NotFound: cannot find 'a'

This is probably because locals() is not checked by resolve_placeholder(). _self_search_list does not contain locals.

The following two cases compile and run without issues:

  1. Compiling without -Xcheetah-cheats produces:

    a = u'foo' b = resolve_placeholder('a', template=self, local_vars=locals(), global_vars=_globals)

  2. Compiling with -Xcheetah-cheats and -O2 produces:

    _self_search_list = self.search_list + [_globals] _buffer_write(u'\n') a = u'foo' b = a

The following case also reproduces the runtime error (compiled with - Xcheetah-cheats and -O2):

if True

#set $a = 'foo'

end if

set $b = $a

Summary: If cheetah-cheats is enabled and the optimizer doesn't hit the resolve_placeholder node, there is a runtime error.

Status: Accepted

Labels:
Type-Defect Priority-Medium