hogoww / Illicium

Translation from Pharo to C
3 stars 1 forks source link

Infinite loop in iterative version of inlining #66

Closed hogoww closed 4 years ago

hogoww commented 4 years ago

I rewrote both the iterative and recursive version of the inlining to use the same inlining code. Now I can safely say that the problem is in the iteration part. When replacing a node, this node is considered useless and its parent is therefore not changed. When visiting, every accessible node of the tree is visited before visiting each sub-node individually sub-nodes. If its sub-nodes change, it does not matter. In the iterative version: #nodesDo:, it uses #children which gives a collection of children. This collection won't be changed, and if a node does not exists post inlining, and causes undefined behavior.

This seems kinda weird, and should probably happen on collections in the AST too such as cascade. I don't have a better explanation regardless.

hogoww commented 4 years ago

Probably was because more nodes were cached by the #do:, than the visitor version which uses less do. We only do one inlining at a time now, so both should work.