Assert that the argument to gen/sample is a generator

Fixes TCHECK-46