-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14956 from mppf/init-eq-assign-error
Add check for both init= = or none Related to issue #8065. Previously, the compiler generated `init=` and `=` for all types, but did so separately. That means that one could use the compiler-generated `=` but a custom `init=` or vice versa. This could in some cases lead to confusing and hard to debug problems if a custom `init=` or `=` was forgotten or included the wrong type signature. To resolve these problems, this PR started by adjusting the compiler to check that if a type has custom `init=`, it does not use the default `=`; and that if a type has a custom `=`, it does not use the default `init=`. The compiler currently only considers the result type (`this` for `init=` and the LHS for `=`) when doing this check. As a result, a type with an `init=` or `=` function with a different type RHS causes the error unless both `=` and `init=` are added for the same type. This does not seem to be an undue burden but could have an impact on determining which types are POD. I recommend that in the future types can opt in to being considered POD (in which case `=` and `init=` will be resolved, and compilerErrors in them issued, but can be removed during optimization). The generalized attribute syntax #14141 would be a reasonable way to do that. Even before this PR, the `range` type needed to opt in to being POD because its `init=` included various checks. Next, this PR adjusted the compiler to also check for a mix of uses of compiler-generated `init=` and custom `init=`; or compiler-generated `=` and custom `=`. This only required adjusting 2 additional tests beyond the tests adjusted for the above rule. In all, this PR required adjusting ~30 tests / modules and almost all of these were tests of record initializers/assignment. Reviewed by @lydia-duncan - thanks! Thanks to many others for discussion about the language design direction. - [x] full local futures testing
- Loading branch information
Showing
47 changed files
with
331 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
testClear.chpl:22: In function 'clear': | ||
testClear.chpl:23: error: Can't clear a dense domain | ||
testClear.chpl:26: In function 'clear': | ||
testClear.chpl:27: error: Can't clear a dense domain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
assignReturns-error.chpl:9: error: The return value of an assignment operator must be 'void'. | ||
assignReturns-error.chpl:13: error: The return value of an assignment operator must be 'void'. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.