From c68efbc282a629bc409299f49b499331e21fec17 Mon Sep 17 00:00:00 2001
From: Zbynek Slajchrt <zbynek.slajchrt@oracle.com>
Date: Tue, 14 Aug 2018 18:31:01 +0200
Subject: [PATCH] Misc. bugs fixed when enabling dplyr

---
 .../com/oracle/truffle/r/ffi/impl/nodes/RForceAndCallNode.java  | 2 +-
 com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g | 1 +
 .../com/oracle/truffle/r/test/builtins/TestBuiltin_tilde.java   | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RForceAndCallNode.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RForceAndCallNode.java
index 9d4e21f1b3..87ffb672da 100644
--- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RForceAndCallNode.java
+++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/RForceAndCallNode.java
@@ -110,7 +110,7 @@ public abstract class RForceAndCallNode extends RBaseNode {
         System.arraycopy(dotArgs.getArguments(), 0, argValuesEx, argValues.size() - 1, dotArgs.getLength());
         final String[] argNames = dotArgs.getSignature().getNames();
         if (argNames != null) {
-            System.arraycopy(argNames, 0, argNamesEx, argValues.size(), dotArgs.getLength());
+            System.arraycopy(argNames, 0, argNamesEx, argValues.size() - 1, dotArgs.getLength());
         }
         argsAndNames = new RArgsValuesAndNames(argValuesEx, ArgumentsSignature.get(argNamesEx));
         return argsAndNames;
diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g
index f4080f8847..61e8a59794 100644
--- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g
+++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g
@@ -461,6 +461,7 @@ colon_expr returns [T v]
 
 unary_expression returns [T v]
     : op=(PLUS | MINUS | NOT | QM) n_ l=unary_expression { $v = builder.call(src($op, last()), operator($op), $l.v); }
+	| op=(TILDE) n_ l=utilde_expr { $v = builder.call(src($op, last()), operator($op), $l.v); }
     | b=power_expr                                  { $v = $b.v; }
     ;
 
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_tilde.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_tilde.java
index 4501558f55..69e7882f9d 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_tilde.java
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/builtins/TestBuiltin_tilde.java
@@ -42,6 +42,7 @@ public class TestBuiltin_tilde extends TestBase {
         assertEval("... ~ 0 + x");
         assertEval("y ~ ...");
         assertEval("y ~ ... + 2");
+        assertEval("x * ~y");
     }
 
     @Test
-- 
GitLab