Skip to content

Commit bac3308

Browse files
committed
update for new compilers
1 parent 04dd7dd commit bac3308

29 files changed

+177
-127
lines changed

source/mir/annotated.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct Annotated(T) {
9696
if (annotations.length == 0)
9797
{
9898
version (D_Exceptions)
99-
throw exc;
99+
{ import mir.exception : toMutable; throw exc.toMutable; }
100100
else
101101
assert(0, excMsg);
102102
}

source/mir/base64.d

+8-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Copyright: 2021 Harrison Ford, Symmetry Investments
77
+/
88
module mir.base64;
99

10+
import mir.exception: toMutable;
11+
1012
package static immutable base64DecodeInvalidCharMsg = "base64: Invalid character encountered.";
1113
package static immutable base64DecodeInvalidLenMsg = "Cannot decode a buffer with given length (not a multiple of 4, missing padding?)";
1214
version(D_Exceptions) {
@@ -78,7 +80,7 @@ private ubyte lookup_decoding(char i, char plusChar = '+', char slashChar = '/')
7880
}
7981
else {
8082
version(D_Exceptions) {
81-
throw base64DecodeInvalidCharException;
83+
throw base64DecodeInvalidCharException.toMutable;
8284
} else {
8385
assert(0, base64DecodeInvalidCharMsg);
8486
}
@@ -110,7 +112,7 @@ void decodeBase64(Appender)(scope const(char)[] data,
110112
if (data.length % 4 != 0)
111113
{
112114
version(D_Exceptions) {
113-
throw base64DecodeInvalidLenException;
115+
throw base64DecodeInvalidLenException.toMutable;
114116
} else {
115117
assert(0, base64DecodeInvalidLenMsg);
116118
}
@@ -137,7 +139,7 @@ void decodeBase64(Appender)(scope const(char)[] data,
137139
if (group[0] == '=' || group[1] == '=')
138140
{
139141
version(D_Exceptions)
140-
throw base64DecodeInvalidCharException;
142+
throw base64DecodeInvalidCharException.toMutable;
141143
else
142144
assert(0, base64DecodeInvalidCharMsg);
143145
}
@@ -151,7 +153,7 @@ void decodeBase64(Appender)(scope const(char)[] data,
151153
if ((i / 4) != ((data.length / 4) - 1))
152154
{
153155
version(D_Exceptions)
154-
throw base64DecodeInvalidCharException;
156+
throw base64DecodeInvalidCharException.toMutable;
155157
else
156158
assert(0, base64DecodeInvalidCharMsg);
157159
}
@@ -166,7 +168,7 @@ void decodeBase64(Appender)(scope const(char)[] data,
166168
else
167169
{
168170
version(D_Exceptions)
169-
throw base64DecodeInvalidCharException;
171+
throw base64DecodeInvalidCharException.toMutable;
170172
else
171173
assert(0, base64DecodeInvalidCharMsg);
172174
}
@@ -180,7 +182,7 @@ void decodeBase64(Appender)(scope const(char)[] data,
180182
if ((i / 4) != ((data.length / 4) - 1))
181183
{
182184
version(D_Exceptions)
183-
throw base64DecodeInvalidCharException;
185+
throw base64DecodeInvalidCharException.toMutable;
184186
else
185187
assert(0, base64DecodeInvalidCharMsg);
186188
}

source/mir/bignum/decimal.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct Decimal(uint size64)
243243
else
244244
{
245245
static immutable exception = new Exception("Can't parse Decimal!" ~ size64.stringof ~ ".");
246-
throw exception;
246+
{ import mir.exception : toMutable; throw exception.toMutable; }
247247
}
248248
}
249249

source/mir/bignum/fixed.d

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ struct UInt(size_t size)
105105
else
106106
{
107107
static immutable exception = new Exception("Can't parse UInt!" ~ size.stringof ~ ".");
108-
throw exception;
108+
{ import mir.exception : toMutable; throw exception.toMutable; }
109109
}
110110
}
111111

@@ -205,7 +205,7 @@ struct UInt(size_t size)
205205
version(D_Exceptions)
206206
{
207207
import mir.bignum.low_level_view: hexStringException;
208-
throw hexStringException;
208+
{ import mir.exception : toMutable; throw hexStringException.toMutable; }
209209
}
210210
else
211211
{
@@ -232,7 +232,7 @@ struct UInt(size_t size)
232232
version(D_Exceptions)
233233
{
234234
import mir.bignum.low_level_view: binaryStringException;
235-
throw binaryStringException;
235+
{ import mir.exception : toMutable; throw binaryStringException.toMutable; }
236236
}
237237
else
238238
{

source/mir/bignum/integer.d

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct BigInt(uint size64)
115115
else
116116
{
117117
static immutable exception = new Exception("Can't parse BigInt!" ~ size64.stringof ~ ".");
118-
throw exception;
118+
{ import mir.exception : toMutable; throw exception.toMutable; }
119119
}
120120
}
121121

@@ -194,7 +194,7 @@ struct BigInt(uint size64)
194194
static immutable bigIntOverflowException = new Exception("BigInt!" ~ size64.stringof ~ ".fromBigEndian: data overflow");
195195
BigInt ret = void;
196196
if (!ret.copyFromBigEndian(data, sign))
197-
throw bigIntOverflowException;
197+
{ import mir.exception : toMutable; throw bigIntOverflowException.toMutable; }
198198
return ret;
199199
}
200200

@@ -766,7 +766,7 @@ struct BigInt(uint size64)
766766
if (ret.fromHexStringImpl!(char, allowUnderscores)(str))
767767
return ret;
768768
version(D_Exceptions)
769-
throw hexStringException;
769+
{ import mir.exception : toMutable; throw hexStringException.toMutable; }
770770
else
771771
assert(0, hexStringErrorMsg);
772772
}
@@ -793,7 +793,7 @@ struct BigInt(uint size64)
793793
if (ret.fromBinaryStringImpl!(char, allowUnderscores)(str))
794794
return ret;
795795
version(D_Exceptions)
796-
throw binaryStringException;
796+
{ import mir.exception : toMutable; throw binaryStringException.toMutable; }
797797
else
798798
assert(0, binaryStringErrorMsg);
799799
}

source/mir/bignum/low_level_view.d

+4-4
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ struct BigUIntView(W)
277277
if (view.fromHexStringImpl!(C, allowUnderscores)(str))
278278
return BigUIntView(cast(W[])view.coefficients);
279279
version(D_Exceptions)
280-
throw hexStringException;
280+
{ import mir.exception : toMutable; throw hexStringException.toMutable; }
281281
else
282282
assert(0, hexStringErrorMsg);
283283
}
@@ -400,7 +400,7 @@ struct BigUIntView(W)
400400
if (view.fromBinaryStringImpl!(C, allowUnderscores)(str))
401401
return BigUIntView(cast(W[])view.coefficients);
402402
version(D_Exceptions)
403-
throw binaryStringException;
403+
{ import mir.exception : toMutable; throw binaryStringException.toMutable; }
404404
else
405405
assert(0, binaryStringErrorMsg);
406406
}
@@ -1343,7 +1343,7 @@ struct BigIntView(W)
13431343
if (ret.fromHexStringImpl!(C, allowUnderscores)(str))
13441344
return cast(BigIntView) ret;
13451345
version(D_Exceptions)
1346-
throw hexStringException;
1346+
{ import mir.exception : toMutable; throw hexStringException.toMutable; }
13471347
else
13481348
assert(0, hexStringErrorMsg);
13491349
}
@@ -1392,7 +1392,7 @@ struct BigIntView(W)
13921392
if (ret.fromBinaryStringImpl!(C, allowUnderscores)(str))
13931393
return cast(BigIntView) ret;
13941394
version(D_Exceptions)
1395-
throw binaryStringException;
1395+
{ import mir.exception : toMutable; throw binaryStringException.toMutable; }
13961396
else
13971397
assert(0, binaryStringErrorMsg);
13981398
}

source/mir/date.d

+14-14
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ struct YearMonthDay
343343
if (timestamp.precision != Timestamp.Precision.day)
344344
{
345345
static immutable exc = new Exception("YearMonthDay: invalid timestamp precision");
346-
throw exc;
346+
{ import mir.exception : toMutable; throw exc.toMutable; }
347347
}
348348
with(timestamp) this(year, cast(Month)month, day);
349349
}
@@ -459,7 +459,7 @@ struct YearMonthDay
459459

460460
static if (useExceptions)
461461
{
462-
if (dayOutOfRange) throw InvalidDay;
462+
if (dayOutOfRange) { import mir.exception : toMutable; throw InvalidDay.toMutable; }
463463
}
464464
else
465465
{
@@ -632,7 +632,7 @@ struct YearMonth
632632
{
633633
static immutable exc = new Exception("Month out of bounds [1, 12]");
634634
if (1 > month || month > 12)
635-
throw exc;
635+
{ import mir.exception : toMutable; throw exc.toMutable; }
636636
this.year = year;
637637
this.month = cast(Month)month;
638638
}
@@ -711,7 +711,7 @@ struct YearMonth
711711
if (timestamp.precision != Timestamp.Precision.month)
712712
{
713713
static immutable exc = new Exception("YearMonth: invalid timestamp precision");
714-
throw exc;
714+
{ import mir.exception : toMutable; throw exc.toMutable; }
715715
}
716716
with(timestamp) this(year, cast(Month)month);
717717
}
@@ -851,7 +851,7 @@ struct YearMonth
851851
if (fromISOExtString(str, ret))
852852
return ret;
853853
static immutable exc = new Exception("Invalid YearMonth string");
854-
throw exc;
854+
{ import mir.exception : toMutable; throw exc.toMutable; }
855855
}
856856

857857
nothrow:
@@ -1087,7 +1087,7 @@ nothrow:
10871087

10881088
static if (useExceptions)
10891089
{
1090-
if (dayOutOfRange) throw InvalidDay;
1090+
if (dayOutOfRange) { import mir.exception : toMutable; throw InvalidDay.toMutable; }
10911091
}
10921092
else
10931093
{
@@ -1482,7 +1482,7 @@ struct YearQuarter
14821482
if (timestamp.precision != Timestamp.Precision.month)
14831483
{
14841484
static immutable exc = new Exception("YearMonth: invalid timestamp precision");
1485-
throw exc;
1485+
{ import mir.exception : toMutable; throw exc.toMutable; }
14861486
}
14871487
with(timestamp) this(year, cast(Month)month);
14881488
}
@@ -1662,7 +1662,7 @@ struct YearQuarter
16621662

16631663
static if (useExceptions)
16641664
{
1665-
if (dayOutOfRange) throw InvalidDay;
1665+
if (dayOutOfRange) { import mir.exception : toMutable; throw InvalidDay.toMutable; }
16661666
}
16671667
else
16681668
{
@@ -2035,7 +2035,7 @@ public:
20352035
if (timestamp.precision != Timestamp.Precision.day)
20362036
{
20372037
static immutable exc = new Exception("Date: invalid timestamp precision");
2038-
throw exc;
2038+
{ import mir.exception : toMutable; throw exc.toMutable; }
20392039
}
20402040
with(timestamp) this(year, cast(Month)month, day);
20412041
}
@@ -2119,9 +2119,9 @@ public:
21192119
this(int _year, int _month, int _day) @safe pure @nogc
21202120
{
21212121
if (!valid!"months"(_month))
2122-
throw InvalidMonth;
2122+
{ import mir.exception : toMutable; throw InvalidMonth.toMutable; }
21232123
if (!valid!"days"(_year, cast(Month) _month, _day))
2124-
throw InvalidDay;
2124+
{ import mir.exception : toMutable; throw InvalidDay.toMutable; }
21252125
this = trustedCreate(_year, _month, _day);
21262126
}
21272127

@@ -3330,7 +3330,7 @@ public:
33303330
Date ret;
33313331
if (fromISOString(str, ret))
33323332
return ret;
3333-
throw InvalidISOString;
3333+
{ import mir.exception : toMutable; throw InvalidISOString.toMutable; }
33343334
}
33353335

33363336
///
@@ -3461,7 +3461,7 @@ public:
34613461
Date ret;
34623462
if (fromISOExtString(str, ret))
34633463
return ret;
3464-
throw InvalidISOExtendedString;
3464+
{ import mir.exception : toMutable; throw InvalidISOExtendedString.toMutable; }
34653465
}
34663466

34673467
///
@@ -3732,7 +3732,7 @@ public:
37323732
Date ret;
37333733
if (fromString(str, ret))
37343734
return ret;
3735-
throw InvalidString;
3735+
{ import mir.exception : toMutable; throw InvalidString.toMutable; }
37363736
}
37373737

37383738
/++

source/mir/ediff.d

+12-11
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ import mir.algorithm.iteration: uniq;
179179
import mir.array.allocation;
180180
import mir.math.common;
181181
import mir.ndslice.sorting: sort;
182-
import std.traits: Unqual, getUDAs, hasUDA, isPointer, PointerTarget;
182+
import std.traits: Unqual, isPointer, PointerTarget;
183+
import mir.internal.meta: getUDAs, hasUDA;
183184

184185
@fmamath:
185186

@@ -405,9 +406,9 @@ template Dependencies(T)
405406
string[] variables;
406407
static foreach (member; __traits(allMembers, T))
407408
{
408-
static if (hasUDA!(__traits(getMember, T, member), Derivative))
409+
static if (hasUDA!(T, member, Derivative))
409410
{
410-
variables ~= getUDAs!(__traits(getMember, T, member), Derivative)[0].variables;
411+
variables ~= getUDAs!(T, member, Derivative)[0].variables;
411412
}
412413
}
413414
return variables.sort.uniq.array.DependsOn;
@@ -478,8 +479,8 @@ template getDerivative(string[] variables, bool strict = true)
478479
alias V = T;
479480
template hasDerivative(string member)
480481
{
481-
static if (hasUDA!(__traits(getMember, V, member), Derivative))
482-
enum hasDerivative = variables == getUDAs!(__traits(getMember, V, member), Derivative)[0].variables;
482+
static if (hasUDA!(V, member, Derivative))
483+
enum hasDerivative = variables == getUDAs!(V, member, Derivative)[0].variables;
483484
else
484485
enum hasDerivative = false;
485486
}
@@ -489,7 +490,7 @@ template getDerivative(string[] variables, bool strict = true)
489490
{
490491
static if (hasDerivative!member)
491492
{
492-
static if (hasUDA!(__traits(getMember, V, member), Minus))
493+
static if (hasUDA!(V, member, Minus))
493494
return -__traits(getMember, value, member);
494495
else
495496
return __traits(getMember, value, member);
@@ -530,16 +531,16 @@ void setDerivatives(bool strict = true, D, E)(scope ref D derivatives, E express
530531
return derivatives.setDerivatives!strict(expression);
531532
else
532533
{
533-
import std.traits: getUDAs, hasUDA, isPointer, PointerTarget;
534+
import std.traits: isPointer, PointerTarget;
534535

535536
static foreach (member; __traits(allMembers, D))
536537
{
537-
static if (hasUDA!(__traits(getMember, D, member), Derivative))
538+
static if (hasUDA!(D, member, Derivative))
538539
{
539-
static if (hasUDA!(__traits(getMember, derivatives, member), Minus))
540-
__traits(getMember, derivatives, member) = -expression.getDerivative!(getUDAs!(__traits(getMember, derivatives, member), Derivative)[0].variables, strict);
540+
static if (hasUDA!(D, member, Minus))
541+
__traits(getMember, derivatives, member) = -expression.getDerivative!(getUDAs!(D, member, Derivative)[0].variables, strict);
541542
else
542-
__traits(getMember, derivatives, member) = expression.getDerivative!(getUDAs!(__traits(getMember, derivatives, member), Derivative)[0].variables, strict);
543+
__traits(getMember, derivatives, member) = expression.getDerivative!(getUDAs!(D, member, Derivative)[0].variables, strict);
543544
}
544545
}
545546
}

source/mir/graph/package.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ GraphSeries!(T, I, J) graphSeries(I = uint, J = size_t, T, Range)(in Range[T] aa
7070
if (index >= keys.length)
7171
{
7272
version(D_Exceptions)
73-
throw exception;
73+
{ import mir.exception : toMutable; throw exception.toMutable; }
7474
else
7575
assert(0, exc_msg);
7676
}
@@ -132,7 +132,7 @@ RCGraph!(I, J) rcgraph(I = uint, J = size_t, KeyIterator, RangeIterator)(Series!
132132
if (index >= keys.length)
133133
{
134134
version(D_Exceptions)
135-
throw exception;
135+
{ import mir.exception : toMutable; throw exception.toMutable; }
136136
else
137137
assert(0, exc_msg);
138138
}

source/mir/interpolate/constant.d

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,12 @@ extern(D):
111111
{
112112
if (x.length < 1)
113113
{
114-
version(D_Exceptions) throw exc_min;
114+
version(D_Exceptions) { import mir.exception : toMutable; throw exc_min.toMutable; }
115115
else assert(0, msg_min);
116116
}
117117
if (x.length != data._lengths[i])
118118
{
119-
version(D_Exceptions) throw exc_eq;
119+
version(D_Exceptions) { import mir.exception : toMutable; throw exc_eq.toMutable; }
120120
else assert(0, msg_eq);
121121
}
122122
_grid[i] = x._iterator;

0 commit comments

Comments
 (0)