-
-
Notifications
You must be signed in to change notification settings - Fork 609
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
Fix Issue 17382 - void main(){}pragma(msg,main()); crashes DMD #7316
Conversation
|
Thanks for your pull request, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Some tips to help speed things up:
Bear in mind that large or tricky changes may require multiple rounds of review and revision. Please see CONTRIBUTING.md for more information. Bugzilla references
|
|
NO! |
Can you be more specific? |
|
the generated header will have |
|
You might be right, however asserts are not errors; assert(0) is used on code paths that should never be taken and the user should never be faced with a failed assert so from this point of view no error is swollen. On the other hand, if you use pragma(msg, foo()) where foo is declared as void foo() {} the output is going to be < void > . Now, in the case of this PR, I agree that there might be cases where < void > is outputted and it shouldn't but I don't know any and it seems that the tests all pass. So, when I was asking you to be specific I was expecting an example. Thank you. |
|
I cannot think of an example as of now. Besides having the hdrgen write-out invalid D is hardly an acceptable solution. I'd rather fix this at the point where the main-symbol is rewritten. |
|
Excuse the drive-by comment given that I know nothing about the compiler, but why does the compiler even try to const-fold |
|
It doesn't matter that it's called main, does it? @RazvanN7 please arrange that a compile-time error with a good message is issued if someone attempts to |
|
@andralex Is this ok? |
src/ddmd/dsymbolsem.d
Outdated
| @@ -2917,6 +2917,11 @@ private extern(C++) final class DsymbolSemanticVisitor : Visitor | |||
| e = resolveProperties(sc, e); | |||
| sc = sc.endCTFE(); | |||
| // pragma(msg) is allowed to contain types as well as expressions | |||
| if (e.type && e.type.ty == Tvoid) | |||
| { | |||
| error(pd.loc, "Cannot pass argument `%s` to `pragma msg` because it is `void`", e.toChars); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing () at toChars call (style doesn't match anywhere in this module).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"has type void" is more pedantically correct, but this is fine as is - thanks
No description provided.