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 #4855 from 9rnsr/fix12829
Issue 12829 - Wrong error line number for closure allocation in @nogc function
- Loading branch information
Showing
4 changed files
with
106 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag12829.d(12): Error: function diag12829.test1 is @nogc yet allocates closures with the GC | ||
fail_compilation/diag12829.d(15): diag12829.test1.__lambda1 closes over variable x at fail_compilation/diag12829.d(14) | ||
fail_compilation/diag12829.d(19): diag12829.test1.bar closes over variable x at fail_compilation/diag12829.d(14) | ||
fail_compilation/diag12829.d(26): Error: function diag12829.test2 is @nogc yet allocates closures with the GC | ||
fail_compilation/diag12829.d(31): diag12829.test2.S.foo closes over variable x at fail_compilation/diag12829.d(28) | ||
--- | ||
*/ | ||
|
||
auto test1() @nogc | ||
{ | ||
int x; | ||
void delegate() @nogc foo = () { | ||
int y = x; | ||
}; | ||
|
||
void bar() | ||
{ | ||
int y = x; | ||
} | ||
auto dg = &bar; | ||
} | ||
|
||
auto test2() @nogc | ||
{ | ||
int x; | ||
struct S | ||
{ | ||
void foo() | ||
{ | ||
int y = x; | ||
} | ||
} | ||
return S(); | ||
} |
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