Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

#20927 #20937

wants to merge 1 commit into from

Conversation

Gauravsh-24
Copy link

@Gauravsh-24 Gauravsh-24 commented Mar 2, 2025

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.

@Gauravsh-24 Gauravsh-24 requested a review from ibuclaw as a code owner March 2, 2025 10:09
@dlang-bot
Copy link
Contributor

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 verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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 references

Your 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 locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#20937"

@thewilsonator thewilsonator mentioned this pull request Mar 2, 2025
@Gauravsh-24
Copy link
Author

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.

@Gauravsh-24 Gauravsh-24 changed the title fixed issue #20927 issue #20927 Mar 2, 2025
Copy link
Contributor

@thewilsonator thewilsonator left a 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
Copy link
Contributor

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?

Copy link
Author

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.

Copy link
Author

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.

Copy link
Contributor

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)

Copy link
Author

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.

Copy link
Author

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.

Copy link
Author

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)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it wright?

@Gauravsh-24 Gauravsh-24 changed the title issue #20927 #20927 Mar 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants