Parser fix: Give error in state switch when ident is not a state

This commit is contained in:
Sei Lisa 2024-05-25 20:04:33 +02:00
parent 1d1aba9687
commit 28de23a03b
3 changed files with 10 additions and 2 deletions

View file

@ -1825,8 +1825,11 @@ list lazy_list_set(list L, integer i, list v)
raise EParseSyntax(self)
# State Switch only searches for states in the global scope
name = self.tok[1] if self.tok[0] == 'IDENT' else 'default'
if name not in self.symtab[0] and (name not in self.globals
or self.globals[name]['Kind'] != 's'):
if (name not in self.symtab[0]
or self.symtab[0][name]['Kind'] != 's'
) and (name not in self.globals
or self.globals[name]['Kind'] != 's'
):
raise EParseUndefined(self)
self.NextToken()
self.expect(';')

View file

@ -0,0 +1,3 @@
default{timer(){state Z;}}
^
(Line 2 char 23): ERROR: Name not defined within scope

View file

@ -0,0 +1,2 @@
integer Z;
default{timer(){state Z;}}