mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 23:58:20 +00:00
Allow returning void expressions where state changes are allowed
In the same places as state changes are allowed, i.e. in places where a parent of the AST node is a WHILE/DO/FOR or an IF without ELSE, it's allowed to use return statements with expressions that return void, e.g. llDie(), provided the function itself is declared as returning void. The construction, when found, is rewritten to '{<void expression>; return;}' because the optimizer is not designed to deal with these monsters. We've renamed the variable SuspiciousStSw to PruneBug, because it's used for both purposes now, though a better name might have been PruneBugPendingChecks, because these are only errors if the IF has an ELSE. We've also added the exception to raise as part of the data stored in the list. Per report by Tonaie Resident.
This commit is contained in:
parent
3cfbbb923c
commit
9d540798b4
5 changed files with 183 additions and 14 deletions
15
run-tests.py
15
run-tests.py
|
@ -368,8 +368,19 @@ class UnitTestRegression(UnitTestCase):
|
|||
parser.parse('default{timer(){[llDie()];}}')
|
||||
parser.parse('default{timer(){llDie();}}')
|
||||
parser.parse('default{timer(){(llDie());}}')
|
||||
parser.parse('default{timer(){for(llDie();1;llDie());}}'
|
||||
, ('optimize',))
|
||||
parser.parse('default{timer(){for(llDie();1;llDie());}}',
|
||||
('optimize',))
|
||||
# 'return <void expr>' works in the same situations as state changes
|
||||
self.assertRaises(lslparse.EParseReturnShouldBeEmpty, parser.parse,
|
||||
'default{timer(){return llDie();}}')
|
||||
self.assertRaises(lslparse.EParseReturnShouldBeEmpty, parser.parse,
|
||||
'default{timer(){if(1)return llDie();else;}}')
|
||||
self.assertRaises(lslparse.EParseReturnShouldBeEmpty, parser.parse,
|
||||
'default{timer(){if(1);else return llDie();}}')
|
||||
self.assertRaises(lslparse.EParseReturnShouldBeEmpty, parser.parse,
|
||||
'default{timer(){return 1;}}')
|
||||
self.assertRaises(lslparse.EParseTypeMismatch, parser.parse,
|
||||
'default{timer(){if(1)return 1;}}')
|
||||
|
||||
class UnitTestCoverage(UnitTestCase):
|
||||
def test_coverage_misc(self):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue