18 changes: 18 additions & 0 deletions test/fail_compilation/ctfe14731.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
TEST_OUTPUT:
---
fail_compilation/ctfe14731.d(16): Error: cannot implicitly convert expression (["a b"]) of type string[] to string
fail_compilation/ctfe14731.d(17): Error: cannot implicitly convert expression (split("a b")) of type string[] to string
---
*/

string[] split(string a)
{
return [a];
}

void main()
{
enum string list1 = "a b".split();
string list2 = "a b".split();
}
21 changes: 18 additions & 3 deletions test/fail_compilation/pragmainline2.d
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
REQUIRED_ARGS: -inline
TEST_OUTPUT:
---
fail_compilation/pragmainline2.d(12): Error: function pragmainline2.foo cannot inline function
fail_compilation/pragmainline2.d(14): Error: function pragmainline2.foo cannot inline function
fail_compilation/pragmainline2.d(22): Error: function pragmainline2.f1t cannot inline function
fail_compilation/pragmainline2.d(25): Error: function pragmainline2.f2t cannot inline function
---
*/

Expand All @@ -13,12 +15,25 @@ void foo()
{
pragma(inline, false);
pragma(inline);
pragma(inline, true);
pragma(inline, true); // this last one will affect to the 'foo'
while (0) { }
}

pragma(inline, true) void f1t() { while (0) {} } // cannot inline
pragma(inline, false) void f1f() { while (0) {} }
pragma(inline) void f1d() { while (0) {} }
void f2t() { pragma(inline, true); while (0) {} } // cannot inline
void f2f() { pragma(inline, false); while (0) {} }
void f2d() { pragma(inline); while (0) {} }

void main()
{
foo();
}

f1t();
f1f();
f1d();
f2t();
f2f();
f2d();
}
34 changes: 33 additions & 1 deletion test/runnable/aliasthis.d
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,10 @@ struct RefCounted12008(T)
return 0;
}

int refCountedPayload() inout;
int refCountedPayload() inout
{
return 0;
}

alias refCountedPayload this;
}
Expand Down Expand Up @@ -1802,6 +1805,34 @@ void test13009()
alias ISput = IS .put;
}

/***************************************************/
// 14806

struct Nullable14806
{
float get() { return float.nan; }
alias get this;
}

struct Foo14806(T)
{
T bar;
Nullable14806 baz;
}

void test14806()
{
Foo14806!int a, b;
assert(a != b);
// ==> a.tupleof != b.tupleof
// ==> a.bar != b.bar || a.baz.get() != b.baz.get()

Foo14806!string c, d;
assert(c != d);
// ==> c.tupleof != d.tupleof
// ==> c.bar != d.bar || c.baz.get() != d.baz.get()
}

/***************************************************/

int main()
Expand Down Expand Up @@ -1857,6 +1888,7 @@ int main()
test11800();
test13490();
test11355();
test14806();

printf("Success\n");
return 0;
Expand Down
15 changes: 15 additions & 0 deletions test/runnable/imports/link14588a.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module imports.link14588a;

void func(alias a)()
{
}

class A
{
int i;

void all()()
{
func!(i)();
}
}
11 changes: 11 additions & 0 deletions test/runnable/imports/link14814a.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module imports.link14814a;

void fun0()
{
}

void fun4()
{
void function()[TypeInfo] funs;
funs[typeid(int)] = &fun0;
}
75 changes: 62 additions & 13 deletions test/runnable/inline.d
Original file line number Diff line number Diff line change
Expand Up @@ -582,13 +582,13 @@ void test14267()
}

/**********************************/
// https://issues.dlang.org/show_bug.cgi?id=14306
// 14306

struct MapResult(alias fun)
{
void front()
{
// while (1) { break; }
// while (1) { break; }
fun(1);
}
}
Expand All @@ -597,32 +597,74 @@ void bar(R)(R r)
{
foreach (i; 0..100)
{
r.front();
r.front();
}
}

struct S {
struct S
{
int x;
int bump() {
while (1) { break; }
++x;
return x;
int bump()
{
while (1) { break; }
++x;
return x;
}
}

void fun(ref S s) {
void fun(ref S s)
{
MapResult!(y => s.bump())().bar;
// MapResult!((int x) => s.bump())().bar;

// MapResult!((int x) => s.bump())().bar;

if (s.x != 100) assert(0);
if (s.x != 100)
assert(0);
}

void test14306() {
void test14306()
{
S t;
fun(t);
}

/**********************************/
// 14754

auto aafunc14754(string k)
{
enum aa = [ "K": "V" ];
auto p = k in aa;
return null;
}

struct MapResult14754(alias fun, R)
{
R _input;

@property auto ref front()
{
return fun(_input[0]);
}
}

auto array14754(R)(R r)
{
alias E = typeof(r.front);
E[] result;
result ~= r.front;
return result;
}

auto mapfun14754(R)(R words, string k)
{
return array14754(MapResult14754!(s => aafunc14754(k), R)(words));
}

void test14754()
{
auto r = mapfun14754([""], "");
}

/**********************************/
// 14606

Expand Down Expand Up @@ -658,6 +700,12 @@ void test14606()
auto t = T14606(null);
}

/**********************************/
// 14753

pragma(inline)
void test14753(string) { }

/**********************************/

int main()
Expand All @@ -681,6 +729,7 @@ int main()
test11394();
test13503();
test14306();
test14754();
test14606();

printf("Success\n");
Expand Down
10 changes: 10 additions & 0 deletions test/runnable/link14588.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// EXTRA_SOURCES: imports/link14588a.d
// PERMUTE_ARGS: -allinst -unittest -debug -inline
// COMPILE_SEPARATELY

import imports.link14588a;

void main()
{
new A().all();
}
10 changes: 10 additions & 0 deletions test/runnable/link14814.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// EXTRA_SOURCES: imports/link14814a.d
// PERMUTE_ARGS: -inline -release -g -O -fPIC
// COMPILE_SEPARATELY

import imports.link14814a;

void main()
{
fun4;
}
25 changes: 25 additions & 0 deletions test/runnable/template9.d
Original file line number Diff line number Diff line change
Expand Up @@ -4573,6 +4573,30 @@ template SubOps14568(Args...)

struct Nat14568 { mixin SubOps14568!(null); }

/******************************************/
// 14735

enum CS14735 { yes, no }

int indexOf14735a(Range )(Range s, in dchar c) { return 1; }
int indexOf14735a(T, size_t n)(ref T[n] s, in dchar c) { return 2; }

int indexOf14735b(Range )(Range s, in dchar c, in CS14735 cs = CS14735.yes) { return 1; }
int indexOf14735b(T, size_t n)(ref T[n] s, in dchar c, in CS14735 cs = CS14735.yes) { return 2; }

void test14735()
{
char[64] buf;

// Supported from 2.063: (http://dlang.org/changelog#implicitarraycast)
assert(indexOf14735a(buf[0..32], '\0') == 2);
assert(indexOf14735b(buf[0..32], '\0') == 2);

// Have to work as same as above.
assert(indexOf14735a(buf[], '\0') == 2);
assert(indexOf14735b(buf[], '\0') == 2);
}

/******************************************/

int main()
Expand Down Expand Up @@ -4683,6 +4707,7 @@ int main()
test13379();
test13484();
test13694();
test14735();

printf("Success\n");
return 0;
Expand Down
140 changes: 140 additions & 0 deletions test/runnable/test42.d
Original file line number Diff line number Diff line change
Expand Up @@ -5412,6 +5412,7 @@ void test9171()
}

/***************************************************/
// 9248

void test9248()
{
Expand All @@ -5421,6 +5422,111 @@ void test9248()
assert(c == [cast(void*)1, cast(void*)2]);
}

/***************************************************/
// 14682

void test14682a()
{
// operands
int[] a1;
int[][] a2;
int[][][] a3;
int[][][][] a4;

// results
int[] r1w = []; assert(r1w.length == 0);
int[][] r2w = []; assert(r2w.length == 0);
int[][][] r3w = []; assert(r3w.length == 0);
int[][][][] r4w = []; assert(r4w.length == 0);
// ----
int[][] r2x = [[]]; assert(r2x.length == 1 && r2x[0].length == 0);
int[][][] r3x = [[]]; assert(r3x.length == 1 && r3x[0].length == 0);
int[][][][] r4x = [[]]; assert(r4x.length == 1 && r4x[0].length == 0);
// ----
int[][][] r3y = [[[]]]; assert(r3y.length == 1 && r3y[0].length == 1 && r3y[0][0].length == 0);
int[][][][] r4y = [[[]]]; assert(r4y.length == 1 && r4y[0].length == 1 && r4y[0][0].length == 0);
// ----
int[][][][] r4z = [[[[]]]]; assert(r4z.length == 1 && r4z[0].length == 1 && r4z[0][0].length == 1 && r4z[0][0][0].length == 0);

// ArrayLiteralExp conforms to the type of LHS.
{ auto x = a1 ~ [] ; static assert(is(typeof(x) == typeof(a1))); assert(x == r1w); } // no ambiguity
{ auto x = a2 ~ [] ; static assert(is(typeof(x) == typeof(a2))); assert(x == r2w); } // fix <- ambiguity
{ auto x = a3 ~ [] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3w); } // fix <- ambiguity
{ auto x = a4 ~ [] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4w); } // fix <- ambiguity
// ----
//{ auto x = a1 ~ [[]] ; } // (see test14682b)
{ auto x = a2 ~ [[]] ; static assert(is(typeof(x) == typeof(a2))); assert(x == r2x); } // no ambiguity
{ auto x = a3 ~ [[]] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3x); } // fix <- ambiguity
{ auto x = a4 ~ [[]] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4x); } // fix <- ambiguity
// ----
static assert(!__traits(compiles, { auto x = a1 ~ [[[]]] ; }));
//{ auto x = a2 ~ [[[]]] ; } // (see test14682b)
{ auto x = a3 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a3))); assert(x == r3y); } // no ambiguity
{ auto x = a4 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a4))); assert(x == r4y); } // fix <- ambiguity
// ----
static assert(!__traits(compiles, { auto x = a1 ~ [[[[]]]]; }));
static assert(!__traits(compiles, { auto x = a2 ~ [[[[]]]]; }));
//{ auto x = a3 ~ [[[[]]]]; } // (see test14682b)
{ auto x = a4 ~ [[[[]]]]; static assert(is(typeof(x) == typeof(a4))); assert(x == r4z); } // no ambiguity

// ArrayLiteralExp conforms to the type of RHS.
{ auto x = [] ~ a1; static assert(is(typeof(x) == typeof(a1))); assert(x == r1w); } // no ambiguity
{ auto x = [] ~ a2; static assert(is(typeof(x) == typeof(a2))); assert(x == r2w); } // fix <- ambiguity
{ auto x = [] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3w); } // fix <- ambiguity
{ auto x = [] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4w); } // fix <- ambiguity
// ----
//{ auto x = [[]] ~ a1; } // (see test14682b)
{ auto x = [[]] ~ a2; static assert(is(typeof(x) == typeof(a2))); assert(x == r2x); } // no ambiguity
{ auto x = [[]] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3x); } // fix <- ambiguity
{ auto x = [[]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4x); } // fix <- ambiguity
// ----
static assert(!__traits(compiles, { auto x = [[[]]] ~ a1; }));
//{ auto x = [[[]]] ~ a2; } // (see test14682b)
{ auto x = [[[]]] ~ a3; static assert(is(typeof(x) == typeof(a3))); assert(x == r3y); } // no ambiguity
{ auto x = [[[]]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4y); } // fix <- ambiguity
// ----
static assert(!__traits(compiles, { auto x = [[[[]]]] ~ a1; }));
static assert(!__traits(compiles, { auto x = [[[[]]]] ~ a2; }));
//{ auto x = [[[[]]]] ~ a3; } // (see test14682b)
{ auto x = [[[[]]]] ~ a4; static assert(is(typeof(x) == typeof(a4))); assert(x == r4z); } // no ambiguity
}

void test14682b()
{
// operands
int[] a1;
int[][] a2;
int[][][] a3;
int[][][][] a4;

// results
int[][] r2a = [[], [] ]; assert(r2a.length == 2 && r2a[0].length == 0 && r2a[1].length == 0);
//int[][][] r3a = [[], [[]] ]; // should work, but doesn't
//int[][][][] r4a = [[], [[[]]]]; // should work, but doesn't
int[][][] r3a; { r3a.length = 2; r3a[0] = []; r3a[1] = [[]] ; }
assert(r3a.length == 2 && r3a[0].length == 0 && r3a[1].length == 1 && r3a[1][0].length == 0);
int[][][][] r4a; { r4a.length = 2; r4a[0] = []; r4a[1] = [[[]]]; }
assert(r4a.length == 2 && r4a[0].length == 0 && r4a[1].length == 1 && r4a[1][0].length == 1 && r4a[1][0][0].length == 0);
// ----
int[][] r2b = [ [] , []]; assert(r2b.length == 2 && r2b[1].length == 0 && r2b[0].length == 0);
//int[][][] r3b = [ [[]] , []]; // should work, but doesn't
//int[][][][] r4b = [[[[]]], []]; // should work, but doesn't
int[][][] r3b; { r3b.length = 2; r3b[0] = [[]] ; r3b[1] = []; }
assert(r3b.length == 2 && r3b[1].length == 0 && r3b[0].length == 1 && r3b[0][0].length == 0);
int[][][][] r4b; { r4b.length = 2; r4b[0] = [[[]]]; r4b[1] = []; }
assert(r4b.length == 2 && r4b[1].length == 0 && r4b[0].length == 1 && r4b[0][0].length == 1 && r4b[0][0][0].length == 0);

// ArrayLiteralExp conforms to the typeof(LHS)->arrayOf().
{ auto x = a1 ~ [[]] ; static assert(is(typeof(x) == typeof(a1)[])); assert(x == r2a); } // fix
{ auto x = a2 ~ [[[]]] ; static assert(is(typeof(x) == typeof(a2)[])); assert(x == r3a); } // fix
{ auto x = a3 ~ [[[[]]]]; static assert(is(typeof(x) == typeof(a3)[])); assert(x == r4a); } // fix

// ArrayLiteralExp conforms to the typeof(RHS)->arrayOf().
{ auto x = [[]] ~ a1; static assert(is(typeof(x) == typeof(a1)[])); assert(x == r2b); } // fix
{ auto x = [[[]]] ~ a2; static assert(is(typeof(x) == typeof(a2)[])); assert(x == r3b); } // fix
{ auto x = [[[[]]]] ~ a3; static assert(is(typeof(x) == typeof(a3)[])); assert(x == r4b); } // fix
}

/***************************************************/
// 9739

Expand Down Expand Up @@ -5877,6 +5983,36 @@ label:
assert(s.num == 10);
}

/***************************************************/
// 14430

void setCookie(long x = 1L << 32L, string y = null){
assert(y.ptr is null);
}

void test14430(){
setCookie();
}

/***************************************************/
// 14510

alias Vector14510 = ulong[3];

void fun14510(Vector14510 vec, bool recursive = false)
{
assert(vec[2] == 0);
if (recursive)
return;
fun14510(vec, true);
}

void test14510()
{
Vector14510 vec;
fun14510(vec);
}

/***************************************************/

int main()
Expand Down Expand Up @@ -6151,6 +6287,8 @@ int main()
test8796();
test9171();
test9248();
test14682a();
test14682b();
test9739();
testdbl_to_ulong();
testdbl_to_uint();
Expand All @@ -6169,6 +6307,8 @@ int main()
test10642();
test7436();
test12138();
test14430();
test14510();

writefln("Success");
return 0;
Expand Down
23 changes: 23 additions & 0 deletions test/runnable/testdt.d
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,29 @@ void test13505()
auto s = S13505();
}

/******************************************/
// 14699

struct S14699a { ubyte[0][10] values; }
struct S14699b { S14699a tbl; }
// +/

ubyte[0][1] sa14699;

void test14699()
{
//auto p = &sa14699; // Cannot work in Win32 (OMF)
}

/******************************************/
// 14805

struct S14805
{
ushort one;
}
auto a14805 = new S14805[513*513];

/******************************************/

int main()
Expand Down
57 changes: 55 additions & 2 deletions test/runnable/xtest46.d
Original file line number Diff line number Diff line change
Expand Up @@ -5636,6 +5636,30 @@ void test7285()
auto sa = spam7285();
}

/***************************************************/
// 14737

void test14737()
{
// compile-time
enum string[2] a1 = ["d", "e"];
enum b1x = ["a", "b", "c"] ~ a1; // Tarray vs Tsarray
enum b1y = a1 ~ ["a", "b", "c"]; // Tsarray vs Tarray
static assert(is(typeof(b1x) == string[]));
static assert(is(typeof(b1y) == string[]));
static assert(b1x == ["a", "b", "c", "d", "e"]);
static assert(b1y == ["d", "e", "a", "b", "c"]);

// runtime
string[2] a2 = ["d", "e"];
auto b2x = ["a", "b", "c"] ~ a2; // Tarray vs Tsarray
auto b2y = a2 ~ ["a", "b", "c"]; // Tsarray vs Tarray
static assert(is(typeof(b2x) == string[]));
static assert(is(typeof(b2y) == string[]));
assert(b2x == ["a", "b", "c", "d", "e"]);
assert(b2y == ["d", "e", "a", "b", "c"]);
}

/***************************************************/
// 7321

Expand Down Expand Up @@ -7281,8 +7305,35 @@ static this()

void test14192()
{
shared int[int] map;
map[1] = 1;
shared int[int] map;
map[1] = 1;
}

/***************************************************/
// 13720

struct FracSec13720
{
this(int hnsecs) {}
}

struct SysTime13720
{
this(TimeOfDay13720 dateTime, FracSec13720 fracSec)
{
}
}

struct TimeOfDay13720
{
~this() { }
}

void assertThrown13720(T)(lazy T) {}

void test13720()
{
assertThrown13720(SysTime13720(TimeOfDay13720.init, FracSec13720(-1)));
}

/***************************************************/
Expand Down Expand Up @@ -7671,6 +7722,7 @@ int main()
test7170();
test7196();
test7285();
test14737();
test7321();
test3282();
test7534();
Expand Down Expand Up @@ -7738,6 +7790,7 @@ int main()
test13437();
test13472();
test13476();
test13720();
test13952();
test13985();
test14211();
Expand Down