Spurious "progress" during final iteration
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 20.6k
- Forks
- 3.3k
- Métriques de merge des PR
- Métriques de PR en attente
Description
I discovered this anomaly while debugging mypy in a different situation #12458.
In the final iteration of semanal_main.process_top_levels, I found that self.progress was being set = True by semanal.add_symbol_table_node.
As it turns out, this setting is ignored in process_top_levels as it's the final iteration. However, the local variable final_iteration becomes False, and that could cause problems in some future version of the code.
I suggest in semanal.add_symbol_table_node, you replace
self.progress = True
with
if not self.final_iteration:
self.progress = True
Now, regarding why a new symbol table node is being added at this late stage, it appears to me to be correct.
What's being added to module X is a dummy definition for a symbol that could not be imported from another module Y because (1) that symbol is undefined in Y or (2) X imports * from Y and that symbol was just added to Y while analyzing Y.
It appears that all possible imported names will get defined, because the SCC ordering guarantees that Y is analyzed before X in situation (2). That's assuming that X and Y are not in a from ... import * cycle.
The cyclic case should be reported as an error, in my opinion. I am filing a separate issue about that.
The dummy definition is a symbol table node with a FakeInfo object, which will get interpreted as Any in later type analysis or error reports. Are you sure you want a FakeInfo? This might lead to some bugs in a future version of the code, and you might want to create a symbol table node with type info for the real Any type.
- Mypy version used: 0.931
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Recherchez semanal_main.process_top_levels et semanal.add_symbol_table_node, puis lisez comment final_iteration et progress interagissent lors du dernier passage. C’est terminé lorsque progress n’est pas défini pendant ce passage, tandis que le comportement de la table des symboles factice reste correct ; vérifiez également si le problème signalé concernant FakeInfo nécessite une modification distincte.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100