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

Improve error message on illegal casts #52

Open
hostilefork opened this issue Jan 16, 2015 · 2 comments
Open

Improve error message on illegal casts #52

hostilefork opened this issue Jan 16, 2015 · 2 comments

Comments

@hostilefork
Copy link
Member

If you write:

Integer value = 10;
Float illegalFloat = static_cast<Float>(value);

The error message that comes back says:

error: call of overloaded 'Float(ren::Integer&)' is ambiguous

Really what it should say is "you can't do that". (Although whether you can do this specific case or not is up for debate in #7) Is there some static_assert or otherwise that could give a better message?

@Morwenn
Copy link
Contributor

Morwenn commented Jan 16, 2015

Wouldn't Float(Integer) = delete; in Float be sufficient? It would probably result in a message along the lines of "use of deleted constructor [...]" while pointing to the deleted constructor and adding a "required from here" pointing to the line where the constructor was called. If you really want to inform the user, put some comment above the deleted constructor.

@hostilefork
Copy link
Member Author

I should have mentioned that it's really all illegal casts that have the lack of a good message (I just noticed this one because it was a test case of something you might think would work...) So the question was about just generally improving the message...

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

No branches or pull requests

2 participants