Skip to content

Commit

Permalink
add warning for calling pure nothrow functions and ignoring the result
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Jun 26, 2011
1 parent 84b4fd1 commit 9b50184
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/expression.c
Expand Up @@ -7548,8 +7548,8 @@ int CallExp::checkSideEffect(int flag)
)
{
result = 0;
//if (flag == 0)
//warning("pure nothrow function %s has no effect", e1->toChars());
if (flag == 0)
warning("pure nothrow function %s has no effect", e1->toChars());
}
else
result = 1;
Expand Down

4 comments on commit 9b50184

@dnadlinger
Copy link
Member

Choose a reason for hiding this comment

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

Just curious – was there a reason for this not to be enabled before?

@dnadlinger
Copy link
Member

Choose a reason for hiding this comment

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

Another thing: What would be the most elegant way to suppress this warning? There are valid use cases where you end up with a pure and nothrow delegate being called, e.g. when just waiting for a std.concurrency message: receive((ShutdownMessage msg, Tid tid){}).

@WalterBright
Copy link
Member Author

Choose a reason for hiding this comment

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

I can't think of an elegant way. If this turns out to be a problem, we'll just remove the warning.

@donc
Copy link
Collaborator

@donc donc commented on 9b50184 Jun 26, 2011 via email

Choose a reason for hiding this comment

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

Please sign in to comment.