Skip to content
Snippets Groups Projects
Commit df3f069f authored by Florian Angerer's avatar Florian Angerer
Browse files

Fix: builtin 'exists' could not handle RMissing.

parent 6847f591
No related branches found
No related tags found
No related merge requests found
......@@ -38,6 +38,7 @@ import com.oracle.truffle.r.runtime.RError.Message;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.RType;
import com.oracle.truffle.r.runtime.builtins.RBuiltin;
import com.oracle.truffle.r.runtime.data.RMissing;
import com.oracle.truffle.r.runtime.data.RPromise;
import com.oracle.truffle.r.runtime.env.REnvironment;
......@@ -68,14 +69,14 @@ public abstract class Exists extends RBuiltinNode.Arg4 {
if (modeType != RType.Any && obj instanceof RPromise) {
obj = PromiseHelperNode.evaluateSlowPath((RPromise) obj);
}
return RRuntime.asLogical(obj != null && RRuntime.checkType(obj, modeType));
return RRuntime.asLogical(obj != null && obj != RMissing.instance && RRuntime.checkType(obj, modeType));
}
for (REnvironment e = env; e != REnvironment.emptyEnv(); e = e.getParent()) {
Object obj = e.get(name);
if (modeType != RType.Any && obj instanceof RPromise) {
obj = PromiseHelperNode.evaluateSlowPath((RPromise) obj);
}
if (obj != null && RRuntime.checkType(obj, modeType)) {
if (obj != null && obj != RMissing.instance && RRuntime.checkType(obj, modeType)) {
return RRuntime.LOGICAL_TRUE;
}
}
......
......@@ -153818,6 +153818,10 @@ $variables
list(k, y, z)
 
 
##com.oracle.truffle.r.test.library.stats.TestRandGenerationFunctions.testDotRandomSeed#
#exists('.Random.seed', envir = .GlobalEnv, inherits = FALSE)
[1] FALSE
##com.oracle.truffle.r.test.library.stats.TestRandGenerationFunctions.testDotRandomSeed#Output.IgnoreErrorContext#
#{ .Random.seed }
Error: object '.Random.seed' not found
......@@ -110,5 +110,7 @@ public class TestRandGenerationFunctions extends TestBase {
assertEval("{ get0('.Random.seed', envir = .GlobalEnv, inherits = FALSE) }");
assertEval(Output.IgnoreErrorContext, "{ get('.Random.seed', envir = .GlobalEnv, inherits = TRUE) }");
assertEval("{ get0('.Random.seed', envir = .GlobalEnv, inherits = TRUE) }");
assertEval("exists('.Random.seed', envir = .GlobalEnv, inherits = FALSE)");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment