Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a warning for generic superclasses that don't include (?) #22784

Merged
merged 10 commits into from
Jul 27, 2023

Conversation

mppf
Copy link
Member

@mppf mppf commented Jul 20, 2023

This PR takes two steps:

  1. It makes it legal to write class C : GenericParent(?) in order to clearly indicate that class C is generic due to inheriting from a generic class.
  2. It adds a warning to request this form when inheriting from a generic class, and a related error for the case of class C : ConcreteParent(?).

The rationale for the warning is that, if code compiling without these warnings (including the field warning from PRs #22745 and #22697) then it is syntactically apparent whether or not a class or record is generic. That means that, in the future, if we make these errors, a) the compiler doesn't have to work as hard to know if a type is generic and b) neither do users.

Reviewed by @vasslitvinov - thanks!

  • full comm=none testing

mppf added a commit that referenced this pull request Jul 27, 2023
)

Resolves Cray/chapel-private#5032

This PR adds a warning for these cases:
* `var x: someGenericType` for fields and variables (need
`someGenericType(?)`)
* `proc foo(type t) { var x: t; }` -- similarly to `var x:
someGenericType`
* `var x: f();` where `f()` returns a generic type, for fields and
variables

In the above, `someGenericType` includes `domain` or user
records/classes that are generic. Note that PR #22697 added a warning
for fields declared with type `domain` or fields of class type with
generic management.

Reviewed by @vasslitvinov - thanks!

- [x] full comm=none testing

Future work
* warn for `class C : SomeGenericType` -- PR #22784
mppf added 9 commits July 27, 2023 10:24
---
Signed-off-by: Michael Ferguson <[email protected]>
---
Signed-off-by: Michael Ferguson <[email protected]>
---
Signed-off-by: Michael Ferguson <[email protected]>
---
Signed-off-by: Michael Ferguson <[email protected]>
---
Signed-off-by: Michael Ferguson <[email protected]>
---
Signed-off-by: Michael Ferguson <[email protected]>
@mppf mppf force-pushed the warn-generic-superclass-no-q branch from 45d48f8 to 8604c89 Compare July 27, 2023 14:28
@mppf mppf marked this pull request as ready for review July 27, 2023 14:31
@mppf mppf requested a review from vasslitvinov July 27, 2023 16:56
Copy link
Member

@vasslitvinov vasslitvinov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. See my wording suggestion(s).

compiler/passes/scopeResolve.cpp Outdated Show resolved Hide resolved
---
Signed-off-by: Michael Ferguson <[email protected]>
@mppf mppf merged commit ec7d920 into chapel-lang:main Jul 27, 2023
7 checks passed
@mppf mppf deleted the warn-generic-superclass-no-q branch July 27, 2023 21:52
mppf added a commit to mppf/chapel that referenced this pull request Aug 4, 2023
Adjusts the warnings from PRs chapel-lang#22697 chapel-lang#22745 and chapel-lang#22784 to include a note
about the warning possibly being an error in the future when compiling
with `--warn-unstable`.

---
Signed-off-by: Michael Ferguson <[email protected]>
mppf added a commit that referenced this pull request Aug 8, 2023
Adjusts the warnings from PRs #22697 #22745 and #22784 to include a note
about the warning possibly being an error in the future when compiling
with `--warn-unstable`.

Reviewed by @lydia-duncan - thanks!

- [x] full comm=none testing
vasslitvinov added a commit to vasslitvinov/chapel that referenced this pull request Aug 15, 2023
Update CoMD's AccumStencilDist to eliminate recent deprecation warnings, especially from chapel-lang#22784 and chapel-lang#22858. CoMD's prediff filters out warnings so newly-introduced warnings go unnoticed in paratest testing.

While there, make some more changes that make CoMD's AccumStencilDist closer to our standard StencilDist.

In particular, change a couple of occurrences of `.low` and `.high` to `.lowBound` and `.highBound`. The corresponding changes in StencilDist were made in chapel-lang#19820 when the warnings on `.low` / `.high` were enabled. Now `.low` / `.high` no longer generate warnings, however have a (slightly) different meaning than they had before chapel-lang#19820.

Future work:

* Should we changes more occurrences of `.low` / `.high` to `.lowBound` / `.highBound` following the changes to StencilDist in chapel-lang#19820?

* Eliminate deprecation warnings about TimeUnits and getCurrentTime() in the llnl version.

* Perhaps the `.prediff` for CoMD should not filter out warnings any more? Implementation-wise, it means that these scripts now should include warnings, if any, in their output.

Signed-off-by: Vassily Litvinov <[email protected]>
vasslitvinov added a commit that referenced this pull request Aug 15, 2023
Update CoMD's AccumStencilDist to eliminate recent deprecation warnings,
especially from #22784 and #22858, following the changes to our standard
StencilDist in those PRs. CoMD's prediff filters out warnings,
so newly-introduced warnings go unnoticed in paratest testing.

While there, make some more changes that make CoMD's AccumStencilDist
closer to our standard StencilDist.

In particular, change a couple of occurrences of `.low` and `.high` to
`.lowBound` and `.highBound`. The corresponding changes in StencilDist
were made in #19820 when the warnings on `.low` / `.high` were enabled.
Now `.low` / `.high` no longer generate warnings, however have a
(slightly) different meaning than they had before #19820.

Future work:

* Should we changes more occurrences of `.low` / `.high` to
`.lowBound` / `.highBound` following the changes to StencilDist in #19820?

* Eliminate deprecation warnings about TimeUnits and getCurrentTime()
in the llnl version.

* Perhaps the `.prediff` for CoMD should not filter out warnings
any longer? Implementation-wise, it means that these scripts should now
include warnings, if any, in their output.

r: @benharsh
mppf added a commit that referenced this pull request Sep 21, 2023
This PR updates the language specification to cover the changes in PRs
#23291 #22784 #22745 #23356 where marking a generic type with `(?)` is
now needed.

This PR adds several new spec sections:
 * Fields with Generic Types
 * Fully Defaulted Generic Types
 * Marking Generic Types

Reviewed by @lydia-duncan - thanks!
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.

4 participants