File tree Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Expand file tree Collapse file tree 1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -179,20 +179,18 @@ strip_stage <- function(expr) {
179
179
if (is_call(uq_expr , c(" after_stat" , " after_scale" ))) {
180
180
uq_expr [[2 ]]
181
181
} else if (is_call(uq_expr , " stage" )) {
182
- # Prefer stat mapping if present
183
- if (! is.null(uq_expr $ after_stat ))
184
- return (uq_expr $ after_stat )
182
+ # Since the argument matching is a bit difficult to get done right,
183
+ # let's actually evaluate it.
184
+ sandbox_env <- env(stage = function (start , after_stat , after_scale ) {
185
+ expr <- enexprs(start = start , after_stat = after_stat )
186
+ if (! is_missing(expr $ after_stat )) {
187
+ expr $ after_stat
188
+ } else {
189
+ expr $ start
190
+ }
191
+ })
185
192
186
- # otherwise original mapping (fallback to scale mapping)
187
- if (! is.null(uq_expr $ start ))
188
- return (uq_expr $ start )
189
-
190
- # The case when after_stat is positionally provided
191
- if (is.null(uq_expr $ after_scale ) && length(uq_expr ) > = 3 )
192
- return (uq_expr [[3 ]])
193
-
194
- # The case when stage() has only one unnamed arg
195
- uq_expr [[2 ]]
193
+ eval_bare(uq_expr , sandbox_env )
196
194
} else {
197
195
expr
198
196
}
You can’t perform that action at this time.
0 commit comments