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:
Sei Lisa 2016-12-25 00:25:49 +01:00
parent d54ba42330
commit f222289673
2 changed files with 18 additions and 1 deletions

View file

@ -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