-
Notifications
You must be signed in to change notification settings - Fork 421
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
Warn for fields declared with generic management or with generic domain type #22697
Conversation
avoid copying the typeExpr if it's not going to be used --- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
--- Signed-off-by: Michael Ferguson <mppf@users.noreply.github.com>
Unless I missed a PR, doesn't this:
make domain fields inconsistent with other generic fields, as in this example: record R {
type t;
var x: t;
}
record S {
var r: R; // no warning about R being generic, needing to be spelled `R(?)`
var s: range; // maybe OK since range is fully-defaulted?
}
var myS = new S(new R(int), 1..10);
writeln(myS); Put another way, I thought we would want to start requiring |
@bradcray - yes, that's accurate in terms of |
) 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
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! - [x] full comm=none testing
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 <mppf@users.noreply.github.com>
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
This PR adds a warning for two cases:
var x: domain
. We want users to writevar x: domain(?)
to emphasize thatdomain
is a generic type and thereforex
is a generic field.var x: C
, whereC
is a class name. These have generic management and cause the field to be generic but that is often unexpected and leads to hard-to-understand errors. We want users to specify memory management explicitly to avoid this kind of genericity. This PR does not introduce a warning for the case where memory management is specified, however the class is generic (that is future work).It adds these warnings in
checkSurprisingGenericDecls
which I plan to extend in the future for warnings for variable declarations likevar x: someGenericRecord;
.For https://github.com/Cray/chapel-private/issues/5031
Some of this PR is based upon earlier work in PR #21404.
Reviewed by @vasslitvinov - thanks!