Conversation
…itor which must override all its elements, so this never happens again
|
Can we do something like |
|
Thanks, added, and verified it works. |
| template<typename SubType, typename ReturnType = void> | ||
| struct OverriddenVisitor { | ||
| // Expression visitors | ||
| ReturnType visitBlock(Block* curr) { |
There was a problem hiding this comment.
Hm, this is a bit verbose. I wonder if we could turn it into a macro a la DELEGATE?
There was a problem hiding this comment.
Hmm, but it stopped working (throwing an error).
There was a problem hiding this comment.
Weird, it looks exactly equivalent except for the extra semicolon (although since I'm nitpicking, it probably shouldn't actually be called DELEGATE since it's not delegating, it's just asserting).
There was a problem hiding this comment.
Looks like static asserts only happen if the code is called. Which is good enough.
There was a problem hiding this comment.
Yeah, it is the same as before. I just happened to test a method that wasn't called now and not earlier ;)
Maybe delegate isn't the best name, but it's also writing a stub for the function with an abort in it, so it's more than the static assert. Maybe "handle"? or "implement"?
There was a problem hiding this comment.
how about unhandled/unimplemented?
dschuff
left a comment
There was a problem hiding this comment.
LGTM, thanks for putting up with me :D
|
The CI failures here are the known issues currently being fixed, merging. |
And add a visitor which must override all its elements, so this never happens again.
If the visitors were virtual methods, they could be
= 0. We use the CRTP pattern here instead, so it's at compile time, and it seems like there should be a way to get the compiler to error at compile time if a method isn't overridden (currently the PR aborts at runtime). Is there a way?