Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add lvalue check for ref/out params with default arguments.
Move def arg check into semantic. Move semantic check to FuncType. Add more tests, do if check before assignment. Separate fail tests. toLvalue can take a scope. Add another test-case.
- Loading branch information
1 parent
77ad29c
commit a4348cc
Showing
5 changed files
with
39 additions
and
0 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 @@ | ||
void test(ref bool val = true) { } |
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 @@ | ||
void test(out bool val = true) { } |
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 @@ | ||
enum x = 3; | ||
void test(ref int val = x) { } |
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,30 @@ | ||
void test7603() | ||
{ | ||
int g; | ||
void foo(int n, ref int r = g) { r = n; } | ||
|
||
int x; | ||
foo(1, x); | ||
assert(x == 1); | ||
|
||
foo(2); | ||
assert(g == 2); | ||
|
||
int h = 100; | ||
void bar(int n, out int r = h) { if (n != 0) r = n; } | ||
|
||
bar(0); | ||
assert(h == 0); | ||
|
||
bar(10); | ||
assert(h == 10); | ||
|
||
bar(10, x); | ||
assert(x == 10); | ||
|
||
bar(0, x); | ||
assert(x == 0); | ||
|
||
} | ||
|
||
void main() { test7603(); } |