-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix split init internal compiler error (#26311)
[reviewed by @mppf] Resolves #19159. Related to #16086, but does not resolve it. Several people ran into this internal compiler error when trying to use tuple syntax to split-initialize some variables. This PR makes it so that those codes now encounter a more understandable user-facing error that at least points them to one way they could adjust their code to avoid it. <details> Allow the split init temporary type to create a ref version of itself. Make it possible to detect the ref version of the temporary type, so that it can be replaced with the appropriate type as part of the expected assignment. Add a new primitive to propagate that type back to the original variable, so that we can get a split init warning at the attempt to split initialize, which will make the error message less confusing. </details> Add the tests from #19159 as futures, linked to #16086 with their new error message. Also add a version of one of the tests with an explicit type, to ensure that the tuple split init works when the variables being initialized have explicit types. Updates the .bad file for test/types/tuple/split-init/multipleInit.chpl so that it matches the new error message. Passed a full paratest with futures
- Loading branch information
Showing
21 changed files
with
82 additions
and
13 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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
initFromAnotherTuple.chpl:2: error: 'x' is not initialized and has no type | ||
initFromAnotherTuple.chpl:2: note: cannot find initialization point to split-init this variable | ||
initFromAnotherTuple.chpl:3: note: 'x' is used here before it is initialized |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var foo = (1,2); | ||
var x,y; | ||
(x, y) = (foo(0), foo(1)); | ||
|
||
writeln(x); | ||
writeln(y); |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feature request: allow split init via tuple syntax when type not declared | ||
#16086 |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | ||
2 |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var foo = (1,2); | ||
var x,y: int; | ||
(x, y) = (foo(0), foo(1)); | ||
|
||
writeln(x); | ||
writeln(y); |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 | ||
2 |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
initFromFunction.chpl:8: error: 'arr1' is not initialized and has no type | ||
initFromFunction.chpl:8: note: cannot find initialization point to split-init this variable | ||
initFromFunction.chpl:9: note: 'arr1' is used here before it is initialized |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
proc return_arrays() { | ||
// some size defining thing only known at runtime in function | ||
var magic_constant : int = 5; | ||
var arr : [0..<magic_constant] int = 0; | ||
return (arr, arr); | ||
} | ||
|
||
var arr1, arr2; | ||
(arr1, arr2) = return_arrays(); | ||
|
||
writeln(arr1); | ||
writeln(arr2); |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feature request: allow split init via tuple syntax when type not declared | ||
#16086 |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
0 0 0 0 0 | ||
0 0 0 0 0 |
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,7 +1,3 @@ | ||
multipleInit.chpl:2: internal error: AST-PRI-IVE-0235 chpl version 1.24.0 pre-release (8b0484037d) | ||
|
||
Internal errors indicate a bug in the Chapel compiler, | ||
and we're sorry for the hassle. We would appreciate your reporting this bug -- | ||
please see https://chapel-lang.org/bugs.html for instructions. In the meantime, | ||
the filename + line number above may be useful in working around the issue. | ||
|
||
multipleInit.chpl:1: error: 'a' is not initialized and has no type | ||
multipleInit.chpl:1: note: cannot find initialization point to split-init this variable | ||
multipleInit.chpl:2: note: 'a' is used here before it is initialized |