mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
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:
parent
d54ba42330
commit
f222289673
2 changed files with 18 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue