Skip to content

BUG: setDoSeq() attempts to remove the incorrect variables on error #25

@HenrikBengtsson

Description

@HenrikBengtsson

Analogously, to setDoPar(), the setDoSeq() function attempts to undo partially set variables in case there's an error;

foreach/R/setDoSeq.R

Lines 31 to 47 in 731cff6

setDoSeq <- function(fun, data=NULL, info=function(data, item) NULL) {
tryCatch(
{
assign('seqFun', fun, pos=.foreachGlobals, inherits=FALSE)
assign('seqData', data, pos=.foreachGlobals, inherits=FALSE)
assign('seqInfo', info, pos=.foreachGlobals, inherits=FALSE)
}, error = function(e) {
if (exists('fun', where=.foreachGlobals, inherits=FALSE))
remove('fun', envir = .foreachGlobals)
if (exists('data', where=.foreachGlobals, inherits=FALSE))
remove('data', envir = .foreachGlobals)
if (exists('info', where=.foreachGlobals, inherits=FALSE))
remove('info', envir = .foreachGlobals)
e
})
}

However, due to what looks like a cut'n'paste mistake from setDoPar(), setDoSeq() removes the wrong variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions