diff --git a/posix.mak b/posix.mak index 592f7b9ca..d0576574a 100644 --- a/posix.mak +++ b/posix.mak @@ -132,7 +132,7 @@ else endif # Set DFLAGS -DFLAGS=-conf= -I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS) -w -de -dip25 $(MODEL_FLAG) $(PIC) +DFLAGS=-conf= -I$(DRUNTIME_PATH)/import $(DMDEXTRAFLAGS) -w -de -dip25 $(MODEL_FLAG) $(PIC) -transition=complex ifeq ($(BUILD),debug) DFLAGS += -g -debug else @@ -322,7 +322,7 @@ $(ROOT)/%$(DOTOBJ): %.c $(CC) -c $(CFLAGS) $< -o$@ $(LIB): $(OBJS) $(ALL_D_FILES) $(DRUNTIME) - $(DMD) $(DFLAGS) -transition=complex -lib -of$@ $(DRUNTIME) $(D_FILES) $(OBJS) + $(DMD) $(DFLAGS) -lib -of$@ $(DRUNTIME) $(D_FILES) $(OBJS) $(ROOT)/libphobos2.so: $(ROOT)/$(SONAME) ln -sf $(notdir $(LIBSO)) $@ diff --git a/std/format.d b/std/format.d index a2853a19d..c34b7114d 100644 --- a/std/format.d +++ b/std/format.d @@ -2590,6 +2590,7 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) /* Formatting a $(D creal) is deprecated but still kept around for a while. */ +deprecated("Use of complex types is deprecated. Use std.complex") private void formatValueImpl(Writer, T, Char)(auto ref Writer w, T obj, const ref FormatSpec!Char f) if (is(Unqual!T : creal) && !is(T == enum) && !hasToString!(T, Char)) { @@ -2604,6 +2605,8 @@ if (is(Unqual!T : creal) && !is(T == enum) && !hasToString!(T, Char)) put(w, 'i'); } +version(TestComplex) +deprecated @safe /*pure*/ unittest // formatting floating point values is now impure { import std.conv : to; @@ -2621,6 +2624,8 @@ if (is(Unqual!T : creal) && !is(T == enum) && !hasToString!(T, Char)) } } +version(TestComplex) +deprecated @system unittest { formatTest( 3+2.25i, "3+2.25i" ); @@ -2641,6 +2646,7 @@ if (is(Unqual!T : creal) && !is(T == enum) && !hasToString!(T, Char)) /* Formatting an $(D ireal) is deprecated but still kept around for a while. */ +deprecated("Use of imaginary types is deprecated. Use std.complex") private void formatValueImpl(Writer, T, Char)(auto ref Writer w, T obj, const ref FormatSpec!Char f) if (is(Unqual!T : ireal) && !is(T == enum) && !hasToString!(T, Char)) { @@ -2650,6 +2656,8 @@ if (is(Unqual!T : ireal) && !is(T == enum) && !hasToString!(T, Char)) put(w, 'i'); } +version(TestComplex) +deprecated @safe /*pure*/ unittest // formatting floating point values is now impure { import std.conv : to; @@ -2661,6 +2669,8 @@ if (is(Unqual!T : ireal) && !is(T == enum) && !hasToString!(T, Char)) } } +version(TestComplex) +deprecated @system unittest { formatTest( 2.25i, "2.25i" ); @@ -5494,20 +5504,22 @@ private bool needToSwapEndianess(Char)(const ref FormatSpec!Char f) s = format("%d %s", 0x1234AF, 0xAFAFAFAF); assert(s == "1193135 2947526575"); +} - //version(X86_64) - //{ - // pragma(msg, "several format tests disabled on x86_64 due to bug 5625"); - //} - //else - //{ - s = format("%s", 1.2 + 3.4i); +version(TestComplex) +deprecated +@system unittest +{ + string s = format("%s", 1.2 + 3.4i); assert(s == "1.2+3.4i", s); +} - //s = format("%x %X", 1.32, 6.78f); - //assert(s == "3ff51eb851eb851f 40D8F5C3"); +@system unittest +{ + import std.conv : octal; - //} + string s; + int i; s = format("%#06.*f",2,12.345); assert(s == "012.35"); diff --git a/std/math.d b/std/math.d index e696a7dd0..c08dd4c07 100644 --- a/std/math.d +++ b/std/math.d @@ -507,7 +507,7 @@ enum real SQRT1_2 = SQRT2/2; /** $(SQRT)$(HALF) // it's quite tricky check for a type who will trigger a deprecation when accessed template isDeprecatedComplex(T) { - static if (__traits(isFloating, T) && __traits(isDeprecated, T)) + static if (__traits(isDeprecated, T)) { enum isDeprecatedComplex = true; } @@ -546,10 +546,11 @@ deprecated unittest * The absolute value of the number. If floating-point or integral, * the return type will be the same as the input; */ -Num abs(Num)(Num x) @safe pure nothrow -if ((is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) || - (is(Num == short) || is(Num == byte))) && - !isDeprecatedComplex!Num) +auto abs(Num)(Num x) +// workaround for https://issues.dlang.org/show_bug.cgi?id=18251 +//if (!isDeprecatedComplex!Num && + //(is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) || + //(is(Num == short) || is(Num == byte)))) { static if (isFloatingPoint!(Num)) return fabs(x); @@ -562,19 +563,22 @@ if ((is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) || } } +import std.meta : AliasSeq; deprecated("Please use std.complex") -auto abs(Num)(Num z) @safe pure nothrow @nogc -if (isDeprecatedComplex!Num) +static foreach (Num; AliasSeq!(cfloat, cdouble, creal, ifloat, idouble, ireal)) { - enum m = Num.mangleof; - // cfloat, cdouble, creal - static if (m == "q" || m == "r" || m == "c") - return hypot(z.re, z.im); - // ifloat, idouble, ireal - else static if (m == "o" || m == "p" || m == "j") - return fabs(z.im); - else - static assert(0, "Unsupported type: " ~ Num.stringof); + auto abs(Num z) @safe pure nothrow @nogc + { + enum m = Num.mangleof; + // cfloat, cdouble, creal + static if (m == "q" || m == "r" || m == "c") + return hypot(z.re, z.im); + // ifloat, idouble, ireal + else static if (m == "o" || m == "p" || m == "j") + return fabs(z.im); + else + static assert(0, "Unsupported type: " ~ Num.stringof); + } } /// ditto diff --git a/std/string.d b/std/string.d index bac4148e8..3c2397601 100644 --- a/std/string.d +++ b/std/string.d @@ -6111,7 +6111,6 @@ if (isSomeString!S || { assert(isNumeric(to!string(real.nan)) == true); assert(isNumeric(to!string(-real.infinity)) == true); - assert(isNumeric(to!string(123e+2+1234.78Li)) == true); } string s = "$250.99-"; @@ -6124,6 +6123,14 @@ if (isSomeString!S || assert(!isNumeric("+")); } +version(TestComplex) +deprecated +unittest +{ + import std.conv : to; + assert(isNumeric(to!string(123e+2+1234.78Li)) == true); +} + /***************************** * Soundex algorithm. * diff --git a/std/traits.d b/std/traits.d index a2da85bcb..dc3159365 100644 --- a/std/traits.d +++ b/std/traits.d @@ -5178,7 +5178,7 @@ template BooleanTypeOf(T) static assert( is(Q!T == BooleanTypeOf!( SubTypeOf!(Q!T) ))); } - static foreach (T; AliasSeq!(void, NumericTypeList, ImaginaryTypeList, ComplexTypeList, CharTypeList)) + static foreach (T; AliasSeq!(void, NumericTypeList, /*ImaginaryTypeList, ComplexTypeList,*/ CharTypeList)) static foreach (Q; TypeQualifierList) { static assert(!is(BooleanTypeOf!( Q!T )), Q!T.stringof); @@ -5229,7 +5229,7 @@ template IntegralTypeOf(T) static assert( is(Q!T == IntegralTypeOf!( SubTypeOf!(Q!T) ))); } - static foreach (T; AliasSeq!(void, bool, FloatingPointTypeList, ImaginaryTypeList, ComplexTypeList, CharTypeList)) + static foreach (T; AliasSeq!(void, bool, FloatingPointTypeList, /*ImaginaryTypeList, ComplexTypeList,*/ CharTypeList)) static foreach (Q; TypeQualifierList) { static assert(!is(IntegralTypeOf!( Q!T ))); @@ -5264,7 +5264,7 @@ template FloatingPointTypeOf(T) static assert( is(Q!T == FloatingPointTypeOf!( SubTypeOf!(Q!T) ))); } - static foreach (T; AliasSeq!(void, bool, IntegralTypeList, ImaginaryTypeList, ComplexTypeList, CharTypeList)) + static foreach (T; AliasSeq!(void, bool, IntegralTypeList, /*ImaginaryTypeList, ComplexTypeList,*/ CharTypeList)) static foreach (Q; TypeQualifierList) { static assert(!is(FloatingPointTypeOf!( Q!T ))); @@ -5293,7 +5293,7 @@ template NumericTypeOf(T) static assert( is(Q!T == NumericTypeOf!( SubTypeOf!(Q!T) ))); } - static foreach (T; AliasSeq!(void, bool, CharTypeList, ImaginaryTypeList, ComplexTypeList)) + static foreach (T; AliasSeq!(void, bool, CharTypeList, /*ImaginaryTypeList, ComplexTypeList*/)) static foreach (Q; TypeQualifierList) { static assert(!is(NumericTypeOf!( Q!T ))); @@ -5354,7 +5354,7 @@ template CharTypeOf(T) static assert( is(CharTypeOf!( SubTypeOf!(Q!T) ))); } - static foreach (T; AliasSeq!(void, bool, NumericTypeList, ImaginaryTypeList, ComplexTypeList)) + static foreach (T; AliasSeq!(void, bool, NumericTypeList, /*ImaginaryTypeList, ComplexTypeList*/)) static foreach (Q; TypeQualifierList) { static assert(!is(CharTypeOf!( Q!T ))); @@ -5386,7 +5386,7 @@ template StaticArrayTypeOf(T) @safe unittest { - static foreach (T; AliasSeq!(bool, NumericTypeList, ImaginaryTypeList, ComplexTypeList)) + static foreach (T; AliasSeq!(bool, NumericTypeList, /*ImaginaryTypeList, ComplexTypeList*/)) static foreach (Q; AliasSeq!(TypeQualifierList, InoutOf, SharedInoutOf)) { static assert(is( Q!( T[1] ) == StaticArrayTypeOf!( Q!( T[1] ) ) )); @@ -5423,7 +5423,7 @@ template DynamicArrayTypeOf(T) @safe unittest { - static foreach (T; AliasSeq!(/*void, */bool, NumericTypeList, ImaginaryTypeList, ComplexTypeList)) + static foreach (T; AliasSeq!(/*void, */bool, NumericTypeList, /*ImaginaryTypeList, ComplexTypeList*/)) static foreach (Q; AliasSeq!(TypeQualifierList, InoutOf, SharedInoutOf)) { static assert(is( Q!T[] == DynamicArrayTypeOf!( Q!T[] ) )); @@ -6090,7 +6090,6 @@ enum bool isEqualityComparable(T) = ifTestable!(T, unaryFun!"a == a"); { static assert(isEqualityComparable!int); static assert(isEqualityComparable!string); - static assert(isEqualityComparable!creal); static assert(!isEqualityComparable!void); struct Foo {} @@ -6110,6 +6109,13 @@ enum bool isEqualityComparable(T) = ifTestable!(T, unaryFun!"a == a"); assert(b1 != b3); } +version(TestComplex) +deprecated +@safe unittest +{ + static assert(isEqualityComparable!creal); +} + /** * Detect whether $(D T) is a struct, static array, or enum that is implicitly * convertible to a string. diff --git a/std/typecons.d b/std/typecons.d index 620301b8d..8b8ebfd77 100644 --- a/std/typecons.d +++ b/std/typecons.d @@ -2300,13 +2300,13 @@ string alignForSize(E...)(const char[][] names...) { enum x = alignForSize!(int[], char[3], short, double[5])("x", "y","z", "w"); struct Foo { int x; } - enum y = alignForSize!(ubyte, Foo, cdouble)("x", "y", "z"); + enum y = alignForSize!(ubyte, Foo, double)("x", "y", "z"); enum passNormalX = x == "double[5] w;\nint[] x;\nshort z;\nchar[3] y;\n"; - enum passNormalY = y == "cdouble z;\nFoo y;\nubyte x;\n"; + enum passNormalY = y == "double z;\nFoo y;\nubyte x;\n"; enum passAbnormalX = x == "int[] x;\ndouble[5] w;\nshort z;\nchar[3] y;\n"; - enum passAbnormalY = y == "Foo y;\ncdouble z;\nubyte x;\n"; + enum passAbnormalY = y == "Foo y;\ndouble z;\nubyte x;\n"; // ^ blame http://d.puremagic.com/issues/show_bug.cgi?id=231 static assert(passNormalX || passAbnormalX && double.alignof <= (int[]).alignof); diff --git a/std/variant.d b/std/variant.d index 327f4834f..a3191364d 100644 --- a/std/variant.d +++ b/std/variant.d @@ -1192,6 +1192,7 @@ public: } } + @system unittest { import std.conv : to; @@ -1484,6 +1485,11 @@ be arbitrarily complex. assert(obj.get!2["customer"] == "John"); } +private struct FakeComplexReal +{ + real re, im; +} + /** Alias for $(LREF VariantN) instantiated with the largest size of `creal`, `char[]`, and `void delegate()`. This ensures that `Variant` is large enough @@ -1492,7 +1498,7 @@ pointers, delegates, and class references. You may want to use $(D VariantN) directly with a different maximum size either for storing larger types unboxed, or for saving memory. */ -alias Variant = VariantN!(maxSize!(creal, char[], void delegate())); +alias Variant = VariantN!(maxSize!(FakeComplexReal, char[], void delegate())); /** * Returns an array of variants constructed from $(D args). @@ -1770,16 +1776,13 @@ static class VariantException : Exception { auto v1 = Variant(42); auto v2 = Variant("foo"); - auto v3 = Variant(1+2.0i); int[Variant] hash; hash[v1] = 0; hash[v2] = 1; - hash[v3] = 2; assert( hash[v1] == 0 ); assert( hash[v2] == 1 ); - assert( hash[v3] == 2 ); } { @@ -1795,6 +1798,15 @@ static class VariantException : Exception } } +version(TestComplex) +deprecated +@system unittest +{ + auto v3 = Variant(1+2.0i); + hash[v3] = 2; + assert( hash[v3] == 2 ); +} + @system unittest { // check comparisons incompatible with AllowedTypes diff --git a/unittest.d b/unittest.d index ac8e07c84..469d61ca8 100644 --- a/unittest.d +++ b/unittest.d @@ -81,11 +81,6 @@ int main(string[] args) std.zlib.adler32(0,null); // D.zlib auto t = task!cmp("foo", "bar"); // parallelism - creal c = 3.0 + 4.0i; - c = sqrt(c); - assert(c.re == 2); - assert(c.im == 1); - printf("args.length = %d\n", args.length); for (int i = 0; i < args.length; i++) printf("args[%d] = '%.*s'\n", i, args[i].length, args[i].ptr);