Skip to content

Commit c1373bb

Browse files
committed
Use implicit conversions instead of casts where equivalent
1 parent b3b668f commit c1373bb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spec/expression.dd

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,19 +1223,21 @@ $(H4 $(LNAME2 cast_integers, Integers))
12231223
---
12241224
)
12251225

1226-
$(P Casting between signed and unsigned types will reinterpret the
1226+
$(P Converting between signed and unsigned types will reinterpret the
12271227
value if the destination type cannot represent the source
12281228
value.)
12291229

12301230
$(SPEC_RUNNABLE_EXAMPLE_RUN
12311231
---
12321232
short c = -1;
1233-
auto d = cast(ushort) c;
1233+
ushort d = c;
12341234
assert(d == ushort.max);
1235+
assert(uint(c) == uint.max);
12351236

12361237
ubyte e = 255;
1237-
auto f = cast(byte) e;
1238-
assert(f == -1);
1238+
byte f = e;
1239+
assert(f == -1); // reinterpreted
1240+
assert(short(e) == 255); // no change
12391241
---
12401242
)
12411243

0 commit comments

Comments
 (0)