Tripped over this problem this evening and was wondering if I'm missing something obvious. I'm converting misc data to strings for output, and found this to not work at all:
boolean is (probably) a nil value. string is a table. type(val) returns a string with the type name, therefore you need to compare it to another string: