Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 09df4c3

Browse files
committed
Merge remote-tracking branch 'upstream/stable' into merge_stable
# Conflicts: # src/object.d
2 parents 52f2367 + 1d72cc4 commit 09df4c3

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/core/internal/string.d

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ alias UnsignedStringBuf = char[20];
1717

1818
char[] unsignedToTempString(ulong value, return char[] buf, uint radix = 10) @safe
1919
{
20+
if (radix < 2)
21+
// not a valid radix, just return an empty string
22+
return buf[$ .. $];
23+
2024
size_t i = buf.length;
2125
do
2226
{
@@ -74,6 +78,10 @@ unittest
7478
assert(long.sizeof.unsignedToTempString == "8");
7579
assert(uint.max.unsignedToTempString == "4294967295");
7680
assert(ulong.max.unsignedToTempString == "18446744073709551615");
81+
82+
// test bad radices
83+
assert(100.unsignedToTempString(buf, 1) == "");
84+
assert(100.unsignedToTempString(buf, 0) == "");
7785
}
7886

7987
alias SignedStringBuf = char[20];
@@ -151,7 +159,7 @@ unittest
151159
* Returns:
152160
* number of digits
153161
*/
154-
int numDigits(uint radix = 10)(ulong value) @safe
162+
int numDigits(uint radix = 10)(ulong value) @safe if (radix >= 2 && radix <= 36)
155163
{
156164
int n = 1;
157165
while (1)
@@ -197,6 +205,11 @@ unittest
197205
assert(1.numDigits!2 == 1);
198206
assert(2.numDigits!2 == 2);
199207
assert(3.numDigits!2 == 2);
208+
209+
// test bad radices
210+
static assert(!__traits(compiles, 100.numDigits!1()));
211+
static assert(!__traits(compiles, 100.numDigits!0()));
212+
static assert(!__traits(compiles, 100.numDigits!37()));
200213
}
201214

202215
int dstrcmp( scope const char[] s1, scope const char[] s2 ) @trusted

src/object.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,7 @@ class Object
957957
}
958958
}
959959

960-
auto opEquals(Object lhs, Object rhs)
960+
bool opEquals(Object lhs, Object rhs)
961961
{
962962
// If aliased to the same object or both null => equal
963963
if (lhs is rhs) return true;
@@ -982,7 +982,7 @@ auto opEquals(Object lhs, Object rhs)
982982
/************************
983983
* Returns true if lhs and rhs are equal.
984984
*/
985-
auto opEquals(const Object lhs, const Object rhs)
985+
bool opEquals(const Object lhs, const Object rhs)
986986
{
987987
// A hack for the moment.
988988
return opEquals(cast()lhs, cast()rhs);

0 commit comments

Comments
 (0)