-
-
Notifications
You must be signed in to change notification settings - Fork 637
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
#20927 #20937
base: master
Are you sure you want to change the base?
#20927 #20937
Conversation
Thanks for your pull request and interest in making D better, @Gauravsh-24! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#20937" |
The file test/test_opcall.d contains a D programming language code snippet that defines a struct Test with an overloaded opCall method. The opCall method is conditionally defined with the if false statement, meaning it will not be compiled or executed. In the main function, an instance of Test is created, which is intended to be interpreted as a constructor call. |
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.
Please retitle the commit message and PR title to give a short summary of what issue #20927
|
||
struct Test | ||
{ | ||
Test opCall() if false |
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.
what's with the if false
?
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.
The line Test opCall() if false indicates that the opCall method is conditionally compiled based on the if false statement. This means that the method will not be available or compiled into the program, effectively making it a no-op.
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.
The main function creates an instance of Test, which will call the default constructor since opCall is not defined due to the if false condition.
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.
in which it should be Test opCall() if (false)
(note the parentheses)
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.
The opCall method is defined within the Test struct but is conditionally compiled based on the if (false) statement, meaning it will not be available in the compiled output.
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.
the code with the if (false) condition in the opCall method. Since the method is conditionally compiled and will not execute, can it will need be modify the condition to if (true) to allow the method to be compiled and executed.
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.
struct Test
{
Test opCall() if (true)
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.
Is it wright?
The file test/test_opcall.d contains a D programming language code snippet that defines a struct Test with an overloaded opCall method. The opCall method is conditionally defined with the if false statement, meaning it will not be compiled or executed.
In the main function, an instance of Test is created, which is intended to be interpreted as a constructor call.