Fix issue 16244 - Prevent an ICE with empty cast#6457
Fix issue 16244 - Prevent an ICE with empty cast#6457WalterBright merged 1 commit intodlang:masterfrom LemonBoy:b16244
Conversation
|
|
This looks okay. |
| visit(cast(UnaExp)e); | ||
| if (!result) | ||
| // e.to can be null for `cast()` | ||
| if (!result && e.to) |
There was a problem hiding this comment.
Hm? A cast with no type is semantically valid albeit just a no-op
There was a problem hiding this comment.
then maybe we can warn ?
uint a = cast()12;
does indeed compile but I feel it's strange to allow that
|
@LemonBoy where does it say that an empty cast is semantically valid ? |
|
@UplinkCoder: Grammatically, it is valid as per the second clause of CastExpression, and the semantics (remove any type modifiers) are documented in the spec. |
|
@klickverbot I'd say we should fix the spec then this makes no sense what-so-ever. |
|
@UplinkCoder: It's quite useful to cast away const/shared/…, and there on purpose. Just because you don't know a part of the language doesn't mean it "makes no sense what-so-ever". |
|
@klickverbot then it is not a no-op. but rather a buitin cast-to-unqual. |
Indeed – I was just replying to your question, and missed @LemonBoy's no-op suggestion. |
|
Rebased, the DAutoTest failure looks unrelated. |
|
@andralex this is ready. |
No description provided.