-
Notifications
You must be signed in to change notification settings - Fork 55
compiler: extend cast syntax for initlists #301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
chqrlie
commented
Jun 23, 2025
- parse compound cast expressions: depending on surrounding code, explicit casts can be more readable than implicit conversions as function arguments or return values.
- add tests
|
We had 'compound literals' before this commit right? Only without the cast. The type was inferred from the LHS. Adding the cast only seems to make the code longer, or am I missing something? |
Yes, this commit implements compound literals:
|
|
What would happen with?
|
This would be a constraint violation, but if we have implicit upcasts, this would work: And if we allow structures to implicitly decay to pointers like arrays, the A more interesting example: Or this one for string conversions: |
d7c864b to
9ac741f
Compare
4bcb1ce to
6d5b83b
Compare
586ba9c to
e18038a
Compare
0a6dba5 to
86e9cd8
Compare
bd2d7fe to
d7dd7e6
Compare
6152319 to
0dd9d89
Compare
250f813 to
9edab7f
Compare
dea0460 to
a92ad5d
Compare
8a9a1b9 to
d33339a
Compare
93be48c to
60106af
Compare
f7cec52 to
fa8f704
Compare
* parse compound cast expressions: depending on surrounding code, explicit casts can be more readable than implicit conversions as function arguments or return values. * add tests.