Skip to content
Snippets Groups Projects
Commit d0b10988 authored by stepan's avatar stepan
Browse files

substitute() returns symbol for missing argument

parent 9f71351e
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -57,6 +57,11 @@ public abstract class Substitute extends RBuiltinNode.Arg2 {
casts.arg(1).defaultError(INVALID_ENVIRONMENT_SPECIFIED).allowNullAndMissing().mustBe(instanceOf(RAbstractListVector.class).or(instanceOf(REnvironment.class)));
}
@Specialization
protected Object doSubstitute(VirtualFrame frame, @SuppressWarnings("unused") RMissing exprMissing, @SuppressWarnings("unused") RMissing envMissing) {
return RSymbol.MISSING;
}
@Specialization
protected Object doSubstitute(VirtualFrame frame, RPromise expr, @SuppressWarnings("unused") RMissing envMissing) {
return doSubstituteWithEnv(expr, REnvironment.frameToEnvironment(frame.materialize()));
......
......@@ -4,7 +4,7 @@
* http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright (c) 2012-2014, Purdue University
* Copyright (c) 2013, 2017, Oracle and/or its affiliates
* Copyright (c) 2013, 2018, Oracle and/or its affiliates
*
* All rights reserved.
*/
......@@ -138,5 +138,7 @@ public class TestBuiltin_substitute extends TestBase {
assertEval("{ foo <- function(...) bar(3+2); bar <- function(...) { ..1; substitute(..1); }; foo(1+2); }");
assertEval("{ foo <- function(...) bar(3+2); bar <- function(...) { substitute(list(...)); }; foo(1+2); }");
assertEval("{ foo <- function(...) bar(3+2); bar <- function(...) { list(...); substitute(list(...)); }; foo(1+2); }");
assertEval("typeof(substitue())");
}
}
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