-
-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow ref on locals, globals, and statics
- Loading branch information
1 parent
e60bfd1
commit c0e8beb
Showing
3 changed files
with
20 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
struct S { int a; } | ||
|
||
void test() | ||
{ | ||
S s; | ||
ref int r1 = s.a; | ||
r1 = 3; | ||
__gshared S t2; | ||
ref int r2 = t2.a; | ||
static S t3; | ||
ref int r3 = t3.a; | ||
extern S t4; | ||
ref int r4 = t4.a; | ||
} |
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,13 +1,15 @@ | ||
/* | ||
TEST_OUTPUT: | ||
--- | ||
fail_compilation/diag9679.d(11): Error: variable `diag9679.main.n` - only parameters, functions and `foreach` declarations can be `ref` | ||
fail_compilation/diag9679.d(12): Error: variable `diag9679.main.n` - storage class `auto` has no effect if type is not inferred, did you mean `scope`? | ||
fail_compilation/diag9679.d(13): Error: variable `diag9679.main.n` - storage class `auto` has no effect if type is not inferred, did you mean `scope`? | ||
fail_compilation/diag9679.d(14): Error: variable `diag9679.main.S.a` - field declarations cannot be `ref` | ||
--- | ||
*/ | ||
|
||
|
||
void main() | ||
{ | ||
if (ref n = 1) {} | ||
if (auto int n = 1) {} | ||
struct S { ref int a; } | ||
} |