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

Add protection for wrong keys in object factory #256

Merged
merged 2 commits into from
Apr 26, 2024

Conversation

gonzaponte
Copy link
Collaborator

If the wrong name is used for, say, a generator, the user gets a wild segfault with zero information about what went wrong. This PR adds protection against bad strings and provides a more helpful message.

Bear in mind that part of the message is compiler-dependent. There are no guarantees that typeid(x).name() gives a human-readable output. Thankfully, most compilers do provide a sensible output, so this might be a good enough compromise between simplicity and correctness.

I also added a test that verifies that the exception is raised.

Copy link
Contributor

@paolafer paolafer left a comment

Choose a reason for hiding this comment

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

Nice utility to make debugging easier! It works fine! Approved.

@paolafer paolafer merged commit f128439 into next-exp:master Apr 26, 2024
1 check passed
@gonzaponte gonzaponte deleted the protection branch April 30, 2024 10:18
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.

2 participants