Skip to content

CLS: display auto-computed instantiations for procedures that are only generic because of array formals#28502

Open
DanilaFe wants to merge 12 commits intochapel-lang:mainfrom
DanilaFe:regularization
Open

CLS: display auto-computed instantiations for procedures that are only generic because of array formals#28502
DanilaFe wants to merge 12 commits intochapel-lang:mainfrom
DanilaFe:regularization

Conversation

@DanilaFe
Copy link
Contributor

@DanilaFe DanilaFe commented Mar 5, 2026

This PR stemmed from my attempt to use CLS with the Mason codebase.

The main trouble with the mason codebase is that nearly every module is written in terms of a main (not main) function that just accepts the CLI arguments for the sub-command, like masonUpdate([] string). The trouble with functions like this is that under the current semantics of Chapel, they are generic. Without any calls to instantiate them1, they are left entirely generic and no useful information is shown in the editor.

This PR improves on this situation by detecting procedures that are only generic due to their array formals, and computed an instantiation of these procedures with the generic formals instantiated with default-rectangular array types. This works as follows:

  • For array formals with the type [] eltType, which can be any rank, we arbitrarily pick a rank of 1, and compute a one-dimensional default-rectangular domain with which to create the array. This is handled by computeDefaultBoundedRange, computeDefaultRectangularDomain, and computeDefaultRectangularArray.
  • For array formals with an explicit domain expression, we create an instantiation of a matching rank. This is handled by rebuildDomainInstance and computeDefaultRectangularArray.

The result:

Screenshot 2026-03-05 at 3 32 10 PM Screenshot 2026-03-05 at 3 32 43 PM

Footnotes

  1. Technically, the main procedure from Mason calls the functions and instantiates them. However, two pieces are missing for that to be reflected in CLS: for one, cross-file instantiations are not collected, and for another, we'd still need to default-instantiate the main proc with a one-dimensional, default-rectangular array of strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant