Preserve identifiers when reconstructing AstMethod#1089
Merged
jasmith-hs merged 3 commits intomasterfrom Jul 13, 2023
Merged
Conversation
…nction. Also migrate both to directly use the EagerAstParameters.getPartiallyResolved to reconstruct the parameters. There's no reason that it wasn't already done this way
…rred. To do this, we need to be aware of if the DeferredParsingException was created when forcing the identifiers to be preserved. So I introduced a new enum to be more readable than the boolean that represented that before
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
IdentifierPreservationStrategyenum which lets aDeferredParsingExceptionknow 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 theDeferredParsingExceptionis 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.modifymethod does some modification onfoo_map: