emmalanguage/emma

Tree.rename doesn't change the name field of defs

ggevay opened this issue · 1 comments

Tree.rename uses substituteSymbols, which operates only on symbols, but doesn't touch the name field of defs.

There are two solution approaches:

  1. Fix rename directly.
  2. Introduce a postpass that fixes the names of defs.

I'm leaning towards 1. It seems to be an invariant of Tree that defs' name fields agree with their symbol's name fields (as evidenced by the fact that showCode gives incorrect result, if it is violated). And the longer the tree is in this inconsistent state, the greater the risk that some code will assume that the names are not messed up, and fail because they are messed up.

Furthermore, I don't see any clear advantage of 2. over 1. Maybe there is some performance advantage in some situations, but I don't think it's much.

Fixed with 10e8b0d