[Chapel Merge] Dyno/CLS: fix bugs in resolution affecting CLS with Mason

Branch: refs/heads/main
Revision: 0281aed4cac6fe8e87f37248fd017177202a811c
Author: DanilaFe
Link: Dyno/CLS: fix bugs in resolution affecting CLS with Mason by DanilaFe · Pull Request #28482 · chapel-lang/chapel · GitHub
Log Message:
Dyno/CLS: fix bugs in resolution affecting CLS with Mason (#28482)

This PR fixes a few bugs that affected resolving the Mason codebase. In
particular, these bugs arose when being more proactive about resolving
the code (following instantiations etc.); they aren't picked up in a
normal testInteractive run.

Anyhow, the bugs were as follows:

  • MultiDecl::children was used to iterate the sub-declarations in a
    multi-decl instead of MultiDecl::decls. The children method is
    inherited from AstNode, and can include other AST nodes such as
    attribute groups. The code should've been using decls, which filters
    for declarations only.
  • Reported mismatched actual indices exceeded the bounds of a CallInfo
    because internally, the resolution machinery switched to trying to
    resolve a method call, inserting a this formal. To fix this, adjust
    CallInfo to track whether the implicit this was added, and adjust
    the machinery that reports the actual index to consider this information
    to return an actual index into the original CallInfo, rather than the
    modified one.
  • In a similar vein, error reporting logic with
    printRejectedCandidates for NoMatchingCandidates error reporting
    used a CallInfo's actual index to index into a Call::actuals list.
    Since Call::actuals returns only the arguments between the ( and )
    of the call, while CallInfo includes the this formal which
    syntactically occurs before the (. To fix this, adjust the code to
    subtract one from the actual index when the call is an explicit method
    call before indexing.

While there, notice that we don't respect the various pragma "error mode..." pragmas for nested modules, so adjust the code to work with
that.

Reviewed by @benharsh -- thanks!

Testing

  • Dyno tests
  • CLS tests

Compare: Comparing 973617d6a7709eeaa65ece8fcabf638deb3ee0e0...821d715344624998d41fad7ab0d174629395514b · chapel-lang/chapel · GitHub

Diff:
M frontend/include/chpl/resolution/resolution-types.h
M frontend/lib/resolution/Resolver.cpp
M frontend/lib/resolution/resolution-error-classes-list.cpp
M frontend/lib/resolution/resolution-queries.cpp
M frontend/lib/resolution/resolution-types.cpp
M frontend/lib/resolution/try-catch-analysis.cpp
M frontend/test/resolution/testResolve.cpp
M tools/chapel-py/src/chapel/lsp/init.py
https://github.com/chapel-lang/chapel/pull/28482.diff