ported partial_evaluation to new top_level_scopes API