Add SyntaxError: too many statically nested blocks.

This commit is contained in:
Dave Halter
2017-07-19 21:56:06 +02:00
parent 65df539e97
commit bf5190c7bf
2 changed files with 32 additions and 2 deletions

View File

@@ -51,13 +51,13 @@ class ErrorFinder(Normalizer):
self._add_syntax_error("invalid syntax", leaf)
elif node.type in _BLOCK_STMTS:
with self._context.add_block(node):
if len(self._context.blocks) == _MAX_BLOCK_SIZE:
self._add_syntax_error("too many statically nested blocks", node)
yield
return
elif node.type in ('classdef', 'funcdef'):
context = self._context
with self._context.add_context(node) as new_context:
if len(context.blocks) == _MAX_BLOCK_SIZE:
self._add_syntax_error("Too many statically nested blocks", node)
self._context = new_context
yield
self._context = context