-
-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix 17351 - Manifest constants can't sometimes be passed by
ref
in …
…CTFE As mentioned in the comment, the fix is crude but works well.
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
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,17 @@ | ||
bool fun(S)(ref S[3] a) { assert(a == [42, 84, 169]); return true; } | ||
bool fun2(S)(ref S a) { return true; } | ||
void main() | ||
{ | ||
static const int[3] sa = [42, 84, 169]; | ||
static const double sa2 = 42.42; | ||
static assert(fun(sa)); | ||
static assert(fun2(sa2)); | ||
} | ||
|
||
int f1(ref const int p) { return p; } | ||
int f2(ref const int[2] p) { return p[0] + p[1]; } | ||
void test2() | ||
{ | ||
static immutable int[2] P = [ 0, 1 ]; | ||
static assert(f2(P) == 1); | ||
} |