Add default parameter to next() to prevent StopIteration exception when no corresponding rawToken is found for '[' token (#3301)
Co-authored-by: Ivar Bonsaksen <ivar.bonsaksen@microchip.com>
This commit is contained in:
parent
2c8c8a5fa6
commit
dc582560cc
|
@ -435,7 +435,11 @@ def getElementDef(nameToken, rawTokens = None):
|
||||||
def createArrayChildrenDefs(ed, token, rawTokens = None):
|
def createArrayChildrenDefs(ed, token, rawTokens = None):
|
||||||
if token.str == '[':
|
if token.str == '[':
|
||||||
if rawTokens is not None:
|
if rawTokens is not None:
|
||||||
foundToken = next(rawToken for rawToken in rawTokens if rawToken.file == token.file and rawToken.linenr == token.linenr and rawToken.column == token.column)
|
foundToken = next((rawToken for rawToken in rawTokens
|
||||||
|
if rawToken.file == token.file
|
||||||
|
and rawToken.linenr == token.linenr
|
||||||
|
and rawToken.column == token.column
|
||||||
|
), None)
|
||||||
|
|
||||||
if foundToken and foundToken.next and foundToken.next.str == ']':
|
if foundToken and foundToken.next and foundToken.next.str == ']':
|
||||||
ed.markAsFlexibleArray(token)
|
ed.markAsFlexibleArray(token)
|
||||||
|
|
Loading…
Reference in New Issue