Index: src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
===================================================================
--- src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(revision 15196)
+++ src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java	(working copy)
@@ -572,7 +572,7 @@
         }
 
         /**
-         * Returns true if role is in relation. Returns false if not a relation or it does not have the role.
+         * Returns the number of primitives in a relation with the specified roles.
          * @param env the environment
          * @param roles The roles to count in the relation
          * @return The number of relation members with the specified role
@@ -1371,7 +1371,17 @@
                 convertedArgs = new Object[args.size()+1];
                 convertedArgs[0] = env;
                 for (int i = 1; i < convertedArgs.length; ++i) {
-                    convertedArgs[i] = Cascade.convertTo(args.get(i-1).evaluate(env), expectedParameterTypes[i]);
+                    if (!expectedParameterTypes[i].isArray()) {
+                        convertedArgs[i] = Cascade.convertTo(args.get(i-1).evaluate(env), expectedParameterTypes[i]);
+                    } else {
+                        Class<?> clazz = expectedParameterTypes[i].getComponentType();
+                        Object[] varargs = (Object[]) Array.newInstance(clazz, args.size() - i + 1);
+                        for (int j = 0; j < args.size() - i + 1; ++j) {
+                            varargs[j] = Cascade.convertTo(args.get(j + i - 1).evaluate(env), clazz);
+                        }
+                        convertedArgs[i] = expectedParameterTypes[i].cast(varargs);
+                        break;
+                    }
                     if (convertedArgs[i] == null && !nullable) {
                         return null;
                     }
Index: test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java
===================================================================
--- test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java	(revision 15196)
+++ test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java	(working copy)
@@ -445,6 +445,16 @@
         /* Check with non-relation */
         e = new Environment(way1, new MultiCascade(), Environment.DEFAULT_LAYER, null);
         assertEquals(0, ExpressionFactory.Functions.count_roles(e, "from", "to"));
+
+        /* Check with actual call to mapcss functions */
+        MapCSSStyleSource source = new MapCSSStyleSource("relation[type=destination_sign] {roles: count_roles(\"from\");}");
+        source.loadStyleSource();
+        assertEquals(1, source.rules.size());
+        e = new Environment(rel1, new MultiCascade(), Environment.DEFAULT_LAYER, null);
+        assertTrue(source.rules.get(0).selector.matches(e));
+        source.rules.get(0).declaration.execute(e);
+        assertEquals((Integer) 1, e.getCascade(Environment.DEFAULT_LAYER).get("roles", null, Integer.class));
+
     }
 
     @Test
