Fix void expressions in FOR loops.

As an enhancement over LSL, we trigger a Type Mismatch when there are void expressions in list constructors, because in LSL, while accepted, they trigger an ugly runtime exception.

This works fine, but then expression lists, where this are checked, are not exclusive of list constructor; they are used in other places. One of these places is the initializer and the iterator of FOR loops. As a consequence, we didn't allow void functions in the FOR initializer or iterator.

Fix by adding another possible value to the parameter 'expected_types' in Parse_expression_list. False means don't allow void either (what Null did before); Null now means allow anything. All callers to Parse_expression_list are changed accordingly. Added corresponding regression test.
This commit is contained in:
Sei Lisa 2016-07-10 01:29:11 +02:00
parent e60457f00e
commit 37483a72cb
2 changed files with 22 additions and 17 deletions

View file

@ -228,13 +228,14 @@ class Test02_Parser(UnitTestCase):
self.parser.parse('default{timer(){vector v;v.x=0;}}')
# Check for exceptions only
p = self.parser.parse('default{timer(){jump x;while(1)@x;}}')
p = self.parser.parse('default{timer(){jump x;do@x;while(1);}}')
p = self.parser.parse('default{timer(){jump x;for(;1;)@x;}}')
p = self.parser.parse('default{timer(){jump x;while(1)@x;}}', ('breakcont',))
p = self.parser.parse('default{timer(){jump x;do@x;while(1);}}', ('breakcont',))
p = self.parser.parse('default{timer(){jump x;for(;1;)@x;}}', ('breakcont',))
self.outscript.output(p)
self.parser.parse('default{timer(){jump x;while(1)@x;}}')
self.parser.parse('default{timer(){jump x;do@x;while(1);}}')
self.parser.parse('default{timer(){jump x;for(;1;)@x;}}')
self.parser.parse('default{timer(){jump x;while(1)@x;}}', ('breakcont',))
self.parser.parse('default{timer(){jump x;do@x;while(1);}}', ('breakcont',))
self.parser.parse('default{timer(){jump x;for(;1;)@x;}}', ('breakcont',))
self.parser.parse('default{timer(){for(llDie();1;llDie());}}')
self.assertRaises(EParseUndefined, self.parser.parse,
'default{timer(){jump x;while(1){@x;}}}')