lawrancej / CompilerKit

Compiler construction library in C.
GNU Lesser General Public License v2.1
55 stars 33 forks source link

Added null check in visitor.c #39

Closed mueschm closed 12 years ago

lawrancej commented 12 years ago

Also, would you be willing to write a test case for the null check in tests/visitor-test.c?

mueschm commented 12 years ago

I added in a test case to show that it returns as planned. I do not think adding an assert instead of a return NULL is a good alternative. Visitor to me seems to be a generic class designed for a very versatile workload. Forcing a constraint on visitor seems like it would just limit the potential use in other areas of code. It may be better to just allow other functions to use an assert on the return value themselves or fail in whatever way is suitable for them.

This is of course just because I have no idea as to what exactly people may choose to do when they implement their own visitors. If you think an assert is better than I will change it. I was just unsure if the question was rhetorical or not.

lawrancej commented 12 years ago

I merged this into master, with changes. I'd like for you to take a look at tests/visitor-test.c. This now tests each possible scenario in visitor.c.