[Chapel Merge] Dyno: enable Iteration over heterogenous tuples

Branch: refs/heads/main
Revision: 3533112b9f164885cde6e3b281199f48e355c65d
Author: DanilaFe
Link: Dyno: enable Iteration over heterogenous tuples by DanilaFe · Pull Request #26634 · chapel-lang/chapel · GitHub
Log Message:
Dyno: enable Iteration over heterogenous tuples (#26634)

Closes https://github.com/Cray/chapel-private/issues/6740.

proc foo(x) {
  compilerWarning(x.type : string);
}

proc helper(xs ...?k) {
  for x in xs {
    foo(x);
  }
}

helper(1, "red", 4.2);

Produces:

─── warning in heterotup.chpl:7 [UserDiagnosticEmitWarning] ───
  Int(64)
      >
    7 |     foo(x);
      >

─── warning in heterotup.chpl:7 [UserDiagnosticEmitWarning] ───
  String
      >
    7 |     foo(x);
      >

─── warning in heterotup.chpl:7 [UserDiagnosticEmitWarning] ───
  Real(64)
      >
    7 |     foo(x);
      >

I implemented this by piggybacking off param loop iteration. The
fundamental principle is the same (in fact, you can consider iteration
over heterogeneous tuples to be by a for param over the tuple's
bounds, accessing each individual element), and we already have a
convenient way to note several iterations of the same loop with
different types.

Reviewed by @benharsh -- thanks!

Testing

  • dyno tests
  • paratest

Compare: Comparing e481a13b5e1c8bcdbdcd8e771175459e8cd601a7...e7fe3925c6e97e3ecf0cfffe7409a8f4b0dc6287 · chapel-lang/chapel · GitHub

Diff:
M frontend/include/chpl/resolution/ResolvedVisitor.h
M frontend/lib/resolution/Resolver.cpp
M frontend/test/resolution/testLoopIndexVars.cpp
https://github.com/chapel-lang/chapel/pull/26634.diff