Skip to content

Commit b7c613e

Browse files
schveiguydlang-bot
authored andcommitted
Add more details on removing many C style cast errors.
1 parent 3e32f47 commit b7c613e

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

changelog/2.105.0.dd

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ $(CHANGELOG_NAV_INJECT)
55
$(VERSION Aug 01, 2023, =================================================,
66

77
$(CHANGELOG_HEADER_STATISTICS
8-
$(VER) comes with 11 major changes and 59 fixed Bugzilla issues.
8+
$(VER) comes with 12 major changes and 59 fixed Bugzilla issues.
99
A huge thanks goes to the
1010
$(LINK2 #contributors, 34 contributors)
1111
who made $(VER) possible.)
@@ -18,6 +18,7 @@ $(LI $(RELATIVE_LINK2 dmd.enum-function,Functions can no longer have `enum` stor
1818
$(LI $(RELATIVE_LINK2 dmd.extern-c-overload,Overloading `extern(C)` functions is now an error))
1919
$(LI $(RELATIVE_LINK2 dmd.private-deprecation-error,Deprecation phase ended for access to private method when overloaded with public method.))
2020
$(LI $(RELATIVE_LINK2 dmd.visionos-version-identifier,Added predefined version identifier `VisionOS`))
21+
$(LI $(RELATIVE_LINK2 dmd.allow-parentheses-for-call,Do not error with a C cast when surrounding a type or expression in parentheses when calling or constructing.))
2122

2223
)
2324

@@ -174,6 +175,30 @@ This is Apple's new operating system for their VR/AR device Vision Pro.
174175
)
175176
)
176177

178+
$(LI $(LNAME2 dmd.allow-parentheses-for-call,Do not error with a C cast when surrounding a type or expression in parentheses when calling or constructing.)
179+
$(P
180+
Previous to this version, an expression like `(IdentifierOrBasicType)(Expression)` would be considered a c-style cast,
181+
and disallowed, even if the `IdentifierOrBasicType` could be used as a callable. This is now allowed, as long as the expression is a call, or a construction.
182+
183+
```
184+
struct S { int x; }
185+
int foo(int x) { return x; }
186+
auto bar = &foo;
187+
188+
// these were previously disallowed
189+
auto s = (S)(5); // equivalent to S(5)
190+
auto f = (foo)(5); // equivalent to foo(5)
191+
auto b = (bar)(5); // equivalent to bar(5)
192+
auto i = (int)(5); // equivalent to int(5), not a cast.
193+
194+
// these are not allowed
195+
auto bad = (int)5; // Error: C style cast illegal, use `cast(int)5`
196+
auto bad2 = (ubyte)(12345); // Error: cannot implicitly convert expression `12345` of type `int` to `ubyte`
197+
```
198+
)
199+
200+
$(P See $(BUGZILLA 24025): Expressions contained in parentheses should not be assumed to be C casts)
201+
)
177202

178203
)
179204

0 commit comments

Comments
 (0)