Preserve identifiers when reconstructing AstMethod #1089
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An aliased macro function (aka a local macro function) can be defined which modifies the value of a non-primitive argument. These are parsed by the Ast parser as AstMethod rather than AstMacroFunction. The AstMethod and AstMacroFunction should reconstruct parameters in the same way so I am making that consistent, by actually using the EagerAstParameter's definition of how to reconstruct itself.
Another change I am making is defining a
IdentifierPreservationStrategy
enum which lets aDeferredParsingException
know if it is thrown by one of these classes which forces preserving identifiers (this is done because of the possibility of modifying a variable. Modifying[]
is different than modifyingmy_list
, which starts as[]
). By adding this information, we know that the partially resolved value within theDeferredParsingException
is done such that the necessary identifiers have been preserved. Previously, ifpreserveIdentifer == true
, we'd ignore the result of the DeferredParsingException, and remake it which led to duplicate work and with the other change I'm making in this PR, would not allow the macro function temp variable logic to work.These new tests demonstrate how we need to preserve
foo_map
, imagining that this.modify
method does some modification onfoo_map
: