click here for my current blog

this blog is no longer maintained and is here only for archival purposes

The things that Should Not Happen

I was completing a Parser for my Compilers subject at uni a couple of days ago, and I ran into an issue where my program (which is written in Java) was ending prematurely without producing any error messages. As I’m not very experienced with Java, I emailed my lecturer asking if he knew what was up. Kindly, he offered to take a look at my source file and tracked down the offending code (that was throwing an exception caught silently by the test framework (that I didn’t write)):

The error is that new_tAST = null before that constructor is called.
If you look back in your code to see what had gone wrong earlier:

// this shouldn’t happen

in parseType() had actually happened:-)

Moral of the story: if it shouldn’t happen, it most certainly will.

Leave a Reply