Skip to content

Commit 79f01c4

Browse files
Fix some null deferences in the test suite (#21617)
1 parent c6c921f commit 79f01c4

5 files changed

Lines changed: 8 additions & 7 deletions

File tree

compiler/test/compilable/mixintype.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ alias Lint = mixin("Int");
44

55
int test1(mixin("int")* p)
66
{
7-
mixin("int")[] a;
8-
mixin("int[]") b;
9-
mixin("int[] c;");
7+
mixin("int")[] a = [1];
8+
mixin("int[]") b = [1];
9+
mixin("int[] c = [1];");
1010
mixin("*p = c[0];");
1111
*p = mixin("c[0]");
1212
return *p + a[0] + b[0] + c[0];

compiler/test/compilable/parens_inc.d

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ void main(){
66
*(x)++=0;
77
(*(x)--)=0;
88
(*x++)=0; // ok
9-
int*[] z;
9+
int a = 1, b = 2;
10+
int*[] z = [&a, &b];
1011
*(z[0])++=0; //ok
1112
(y[0])--;
1213
*x++=0;

compiler/test/compilable/test17146.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ struct S { int[] a; int b; }
66

77
void foo()
88
{
9-
S[] s;
9+
S[] s = [S([],0)];
1010
if (s[$-1] == S.init) {}
1111
}
1212

compiler/test/fail_compilation/test18282.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fail_compilation/test18282.d(53): Error: escaping a reference to local variable
1515

1616
string* f() @safe
1717
{
18-
scope string*[] ls;
18+
scope string*[] ls = [null];
1919
return ls[0];
2020
}
2121

compiler/test/runnable/constfold.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class C8939regression
418418
string[2] str;
419419
refValue(str[n1]);
420420

421-
int[] da;
421+
int[] da = [1];
422422
refValue(da[n2]);
423423

424424
int n; int* p = &n;

0 commit comments

Comments
 (0)