Skip to content

Incorrect handling of promises doing reflection #1315

@rihafilip

Description

@rihafilip

When compiling a function which takes as an argument a promise that changes the environment, the environment that is being changed is the incorrect one.

Runnning the following example with PIR_WARMUP=3 PIR_OSR=0

f <- function(x) {
    x + x
}

h <- function() {
    assign("x", 1L, sys.frame(-2))
    42
}

for (i in 1:15) {
    i <- f(h())
    print(i)
}

the printed number should be 43, but after compilation it is 84.
After that, if x is accessed from the top level, it returns 1.
Therefore, the environment that is being modified is not the callee (f), but the global environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions