Throw exception on template expression in batch statements

Related to #829