Allow lists to contain void elements if not optimizing and not lazy

LSO allows this. The compiler does too, but it chokes in RAIL.

This affected a test, which has been adjusted too.

Untyped lazy list elements can no longer be used in isolation in expression lists (including FOR initializator and iterator).

Also rename the terribly named 'self.forbidlabels' to 'self.optenabled' which is more descriptive.
This commit is contained in:
Sei Lisa 2018-04-09 18:42:31 +02:00
parent 4a554d60e8
commit 1afe1643c0
2 changed files with 11 additions and 4 deletions

View file

@ -1628,6 +1628,9 @@ list lazy_list_set(list L, integer i, list v)
if self.tok[0] not in (']', ')', ';'):
while True:
expr = self.Parse_expression()
if expr.nt == 'SUBIDX' and expr.t is None:
# Don't accept an untyped lazy list in expression lists
raise EParseTypeMismatch(self)
if False is not expected_types is not None:
if idx >= len(expected_types):
raise EParseFunctionMismatch(self)
@ -1635,7 +1638,8 @@ list lazy_list_set(list L, integer i, list v)
expr = self.autocastcheck(expr, expected_types[idx]);
except EParseTypeMismatch:
raise EParseFunctionMismatch(self)
elif expected_types is False: # don't accept void expressions
elif expected_types is False and self.optenabled:
# don't accept void expressions if optimization is on
if expr.t not in types:
raise EParseTypeMismatch(self)
idx += 1
@ -1695,7 +1699,7 @@ list lazy_list_set(list L, integer i, list v)
return nr(nt=';', t=None)
if tok0 == '@':
if not AllowDecl and self.forbidlabels:
if not AllowDecl and self.optenabled:
raise EParseInvalidLabelOpt(self)
self.NextToken()
self.expect('IDENT')
@ -2775,7 +2779,7 @@ list lazy_list_set(list L, integer i, list v)
# includes a label as the immediate child of FOR, IF, DO or WHILE.
# If optimization is on, such a label will raise an error. That
# coding pattern is normally easy to work around anyway.
self.forbidlabels = 'optimize' in options
self.optenabled = 'optimize' in options
# Symbol table:
# This is a list of all local and global symbol tables.