forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dyno: fix 'called expression' detection (chapel-lang#24723)
Fixes Cray/chapel-private#6077. Dyno handles resolving base expressions (e.g., the `f` in `f(x)`) differently than plain expressions; this is because, although `a.b` should be a field access, if we know that it's actually `a.b(c, d)`, we need to resolve the method `b` on `a` with arguments `c` and `d` (which happens when the call itself is resolved). Thus, resolution of `a.b` is deferred. However, Dyno's detection of when an expression is the "called expression" is incorrect. In particular, it doesn't work for nested called expressions, like `a.b(x).c(y)`. This is because the `Resolver` only uses a single state variable, `inLeafCall`, which it sets on entering a call, and resets to `nullptr` upon exiting a call. Unfortunately, since the entering and exiting are different functions called at different times, `exit` doesn't know the original / prior value of `inLeafCall`, and as a result, resets it to `nullptr`. This means that in the nested call case, when handling the outer call, `inLeafCall` is incorrectly `nullptr`. This PR fixes the issue by switching to using a stack of called expressions. By doing so, we can preserve the original value of what used to be `inLeafCall`, and thus correctly detect called sub-expressions even when calls are chained / nested. While there, this PR ensures that resetting `inLeafCall` is properly _unset_. Some early-return logic in `exit(Call)` skips unsetting it. To handle this while preserving the elegance of the early-return logic, I put the `exit(Call)` logic into a helper function, and always invoke `pop_back` after calling the helper. Reviewed by @benharsh -- thanks! ## Testing - [x] paratest
- Loading branch information
Showing
3 changed files
with
100 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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