diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ListAccessNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ListAccessNodes.java index f1e3036783898b9ad48b5e7ac6421db16af3fa00..d33dce24251486421bac34e98ff080935c1f10e0 100644 --- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ListAccessNodes.java +++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/ListAccessNodes.java @@ -63,6 +63,9 @@ public final class ListAccessNodes { @Specialization protected Object car(RArgsValuesAndNames args) { + if (args.isEmpty()) { + return RNull.instance; + } return args.getArgument(0); } diff --git a/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/tests/pairlists.R b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/tests/pairlists.R new file mode 100644 index 0000000000000000000000000000000000000000..8260d0d90eadf62d3367a3bf8101ae1792500977 --- /dev/null +++ b/com.oracle.truffle.r.test.native/packages/testrffi/testrffi/tests/pairlists.R @@ -0,0 +1,11 @@ +# Some more tests that work with pairlists and related objects like '...' or language +stopifnot(require(testrffi)) + +# Note: GNU R returns the promise, FastR the value, we check that at least there are not exceptions +foo <- function(...) api.CAR(get('...')) +invisible(foo(a=3)) +invisible(foo(a=4, b=6)) + +foo <- function(...) api.CDR(get('...')) +is.null(foo(a=3)) +names(foo(a=4, b=6))