Skip to content

remove defensive null check#23208

Closed
WalterBright wants to merge 1 commit into
dlang:masterfrom
WalterBright:defensive2
Closed

remove defensive null check#23208
WalterBright wants to merge 1 commit into
dlang:masterfrom
WalterBright:defensive2

Conversation

@WalterBright
Copy link
Copy Markdown
Member

dmd is full of pointers. If we start adding defensive checks, there would be a lot of clutter. It's better to only check if the pointer being null is legitimate. Otherwise, a seg fault and stack trace are needed to find the actual bug rather than paper it over.

For reference: https://github.com/dlang/dmd/pull/23194/changes

@dlang-bot
Copy link
Copy Markdown
Contributor

Thanks for your pull request, @WalterBright!

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#23208"

@WalterBright
Copy link
Copy Markdown
Member Author

Clearly, this was not a defensive piece of code, it was a necessary one.

@WalterBright WalterBright deleted the defensive2 branch June 1, 2026 19:32
@dkorpel
Copy link
Copy Markdown
Contributor

dkorpel commented Jun 1, 2026

What I meant with "defensive" is that from the rest of the code, a possible null value for the FuncDeclaration parameter was assumed to be possible, so I applied it more consistently. I later added a test case for that code path to make sure it was needed and that it wouldn't regress, which obviously failed when you remove the check in this PR, so it's working!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants