From 77ea1867dfc28a744bca5c00ea0a9fbc816874c5 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Thu, 15 Mar 2018 17:32:11 +0100 Subject: [PATCH] Fix seq_along with empty args --- .../com/oracle/truffle/r/nodes/builtin/base/SeqFunctions.java | 3 ++- .../src/com/oracle/truffle/r/test/ExpectedTestOutput.test | 4 ++++ .../oracle/truffle/r/test/builtins/TestBuiltin_seq_along.java | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/SeqFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/SeqFunctions.java index c3fd500728..ee2e6a9758 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/SeqFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/SeqFunctions.java @@ -354,7 +354,8 @@ public final class SeqFunctions { @Child private ClassHierarchyNode classHierarchyNode = ClassHierarchyNode.create(); static { - Casts.noCasts(SeqAlong.class); + Casts casts = new Casts(SeqAlong.class); + casts.arg(0).mustNotBeMissing(Message.ARGUMENTS_PASSED, 0, "'seq_along'", 1); } @Specialization(guards = "!hasClass(value)") diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test index 440ac65414..57f734463d 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/ExpectedTestOutput.test @@ -67789,6 +67789,10 @@ integer(0) [41] 26163.27 26367.35 26571.43 26775.51 26979.59 27183.67 27387.76 27591.84 [49] 27795.92 28000.00 +##com.oracle.truffle.r.test.builtins.TestBuiltin_seq_along.testWithNonStandardLength# +#seq_along() +Error in seq_along() : 0 arguments passed to 'seq_along' which requires 1 + ##com.oracle.truffle.r.test.builtins.TestBuiltin_seq_along.testWithNonStandardLength# #{ assign('length.myclass', function(...) 42, envir=.__S3MethodsTable__.); x <- 1; class(x) <- 'myclass'; res <- seq_along(x); rm('length.myclass', envir=.__S3MethodsTable__.); res } [1] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_seq_along.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_seq_along.java index e71494b48a..833573507b 100644 --- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_seq_along.java +++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_seq_along.java @@ -141,5 +141,6 @@ public class TestBuiltin_seq_along extends TestBase { assertEval(Output.IgnoreWarningContext, Output.IgnoreErrorContext, "{ x <- c(1,2,3); class(x) <- 'myclass'; length.myclass <- function(w) 'hello world'; seq_along(x) }"); assertEval("{ length <- function(x) 42; seq_along(c(1,2,3)) }"); assertEval("{ assign('length.myclass', function(...) 42, envir=.__S3MethodsTable__.); x <- 1; class(x) <- 'myclass'; res <- seq_along(x); rm('length.myclass', envir=.__S3MethodsTable__.); res }"); + assertEval("seq_along()"); } } -- GitLab