-
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
88fc759 to
97c931f
Compare
d02610d to
69f8f60
Compare
41db61a to
f60f1ac
Compare
2acbfbc to
4bdd8f7
Compare
d7dd7e6 to
91f4bde
Compare
04b4c8c to
5cfa267
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.