Skip to content

Commit 07e00c8

Browse files
iprtelIngo PrötelIngo Prötelhsutter
authored
Ensure valid type name for operators with multiple returns. (#796)
* Ensure valid type name for operators with multiple returns. * Added parent and bracket operator. * Added test * Tweak the implementation and run regressions * Use unused parameter to make tests compile cleanly --------- Co-authored-by: Ingo Prötel <[email protected]> Co-authored-by: Ingo Prötel <[email protected]> Co-authored-by: Herb Sutter <[email protected]>
1 parent 06f3173 commit 07e00c8

13 files changed

+179
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,4 @@
2626
*.bin
2727
*.exe
2828
source/gen_version.bat
29+
build*/
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
A : type = {
3+
operator() : (this) -> (x: int, y: int) = {
4+
x = 12;
5+
y = 34;
6+
return;
7+
}
8+
operator* : (this) -> (x: int, y: int) = {
9+
x = 23;
10+
y = 45;
11+
return;
12+
}
13+
operator[] : (this, idx: int) -> (x: int, y: int) = {
14+
x = 34 * (idx+1);
15+
y = 56 * (idx+1);
16+
return;
17+
}
18+
}
19+
20+
21+
main : () = {
22+
23+
a : A = ();
24+
25+
t1 := a();
26+
std::cout << t1.x << " , " << t1.y << "\n";
27+
28+
t2 := a*;
29+
std::cout << t2.x << " , " << t2.y << "\n";
30+
31+
t3 := a[0];
32+
std::cout << t3.x << " , " << t3.y << "\n";
33+
34+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
12 , 34
2+
23 , 45
3+
34 , 56

regression-tests/test-results/clang-12/pure2-return-tuple-operator.cpp.output

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
12 , 34
2+
23 , 45
3+
34 , 56

regression-tests/test-results/gcc-10/pure2-return-tuple-operator.cpp.output

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
12 , 34
2+
23 , 45
3+
34 , 56

regression-tests/test-results/gcc-13/pure2-return-tuple-operator.cpp.output

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
12 , 34
2+
23 , 45
3+
34 , 56
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pure2-return-tuple-operator.cpp

0 commit comments

Comments
 (0)