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 #5202 from 9rnsr/fix14965
[REG2.031] Issue 14965 - Forward reference to inferred return type of function call when using auto return type
- Loading branch information
Showing
12 changed files
with
259 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/fail14965.d(19): Error: forward reference to inferred return type of function 'foo1' | ||
fail_compilation/fail14965.d(20): Error: forward reference to inferred return type of function 'foo2' | ||
fail_compilation/fail14965.d(22): Error: forward reference to inferred return type of function 'bar1' | ||
fail_compilation/fail14965.d(23): Error: forward reference to inferred return type of function 'bar2' | ||
fail_compilation/fail14965.d(25): Error: forward reference to inferred return type of function 'baz1' | ||
fail_compilation/fail14965.d(26): Error: forward reference to inferred return type of function 'baz2' | ||
fail_compilation/fail14965.d(30): Error: forward reference to inferred return type of function 'foo1' | ||
fail_compilation/fail14965.d(31): Error: forward reference to inferred return type of function 'foo2' | ||
fail_compilation/fail14965.d(33): Error: forward reference to inferred return type of function 'bar1' | ||
fail_compilation/fail14965.d(34): Error: forward reference to inferred return type of function 'bar2' | ||
fail_compilation/fail14965.d(36): Error: forward reference to inferred return type of function 'baz1' | ||
fail_compilation/fail14965.d(37): Error: forward reference to inferred return type of function 'baz2' | ||
--- | ||
*/ | ||
|
||
auto foo1() { alias F = typeof(foo1); } // TypeTypeof | ||
auto foo2() { alias FP = typeof(&foo2); } // TypeTypeof | ||
|
||
auto bar1() { auto fp = &bar1; } // ExpInitializer | ||
auto bar2() { auto fp = cast(void function())&bar2; } // castTo | ||
|
||
auto baz1() { return &baz1; } // ReturnStatement | ||
auto baz2() { (&baz2); } // ExpStatement | ||
|
||
class C | ||
{ | ||
auto foo1() { alias F = typeof(this.foo1); } | ||
auto foo2() { alias FP = typeof(&this.foo2); } | ||
|
||
auto bar1() { auto fp = &this.bar1; } | ||
auto bar2() { auto dg = cast(void delegate())&this.bar2; } | ||
|
||
auto baz1() { return &baz1; } | ||
auto baz2() { (&baz2); } | ||
} |
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,15 +1,17 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/test9176.d(12): Error: forward reference to inferred return type of function call 'get' | ||
fail_compilation/test9176.d(13): Error: forward reference to inferred return type of function call 'get()' | ||
--- | ||
*/ | ||
|
||
void foo(int x) {} | ||
static assert(!is(typeof(foo(S())))); | ||
|
||
struct S { | ||
struct S | ||
{ | ||
auto get() { return get(); } | ||
alias get this; | ||
} | ||
|
||
void main(){} |
Oops, something went wrong.