alexmojaki / alexmojaki/birdseye

"too many statically nested blocks" error in long elif chain

Abierto
#16 2 comentarios 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
JavaScript
Estrellas
1.7k
Forks
73
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

MCVE:

```python
from birdseye import eye

@eye
def foo():
if 0:
pass
elif 0:
pass
elif 1:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
elif 0:
pass
```

The reason this happens is that:

> [elif clauses don’t have a special representation in the AST, but rather appear as extra If nodes within the orelse section of the previous one.](https://greentreesnakes.readthedocs.io/en/latest/nodes.html#If)

which leads to many hidden nested `with` blocks created when transforming the AST to trace statements.

It should be possible to fix this by only wrapping the body of each elif/else block in a with statement.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.