Fix crash on non-computable function.
When we reduced the scope of the try block in commit a823158, we introduced a bug because the tree modification was attempted even if no value was assigned (when the exception was triggered). Returning when the function is not computable ensures that this won't happen.
Scaringly, there was no check that caught this.
This commit is contained in:
@@ -974,7 +974,8 @@ class foldconst(object):
|
||||
value = fn(*args)
|
||||
except lslfuncs.ELSLCantCompute:
|
||||
# Don't transform the tree if function is not computable
|
||||
pass
|
||||
return
|
||||
|
||||
del args
|
||||
if not self.foldtabs:
|
||||
generatesTabs = (
|
||||
|
||||
@@ -504,6 +504,22 @@ class Test03_Optimizer(UnitTestCase):
|
||||
'}\n'
|
||||
)
|
||||
|
||||
p = self.parser.parse('default{timer(){\n'
|
||||
'integer i = llGetAgentInfo("12345678-9ABC-DEF0-0123-456789ABCDEF");\n'
|
||||
'}}\n'
|
||||
)
|
||||
self.opt.optimize(p, ('optimize','constfold'))
|
||||
out = self.outscript.output(p)
|
||||
self.assertEqual(out, 'default\n'
|
||||
'{\n'
|
||||
' timer()\n'
|
||||
' {\n'
|
||||
' integer i = llGetAgentInfo("12345678-'
|
||||
'9ABC-DEF0-0123-456789ABCDEF");\n'
|
||||
' }\n'
|
||||
'}\n'
|
||||
)
|
||||
|
||||
try:
|
||||
self.parser.parse('default { timer() { return } }')
|
||||
# should raise EParseSyntax, so it should never get here
|
||||
|
||||
Reference in New Issue
Block a user