Support unbound function in patch_document