]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Genie: Fix functions can take only one Generic as argument (611191)
authorJamie McCracken <jamie.mccrack@gmail.com>
Wed, 29 Aug 2012 03:24:20 +0000 (23:24 -0400)
committerJamie McCracken <jamie.mccrack@gmail.com>
Wed, 29 Aug 2012 03:24:20 +0000 (23:24 -0400)
vala/valagenieparser.vala

index fe23c5f40659e1f4fedcbc151d1ad3cfb173e454..77fbd1c5dca17033ff703a5f5aa7560bc422c5ae 100644 (file)
@@ -3732,33 +3732,53 @@ public class Vala.Genie.Parser : CodeVisitor {
 
        void skip_type_argument_list () throws ParseError {
                if (accept (TokenType.OF)) {
-                       do {
-                               skip_type ();
-                       } while (accept (TokenType.COMMA));
+               if (accept (TokenType.OPEN_PARENS)) {
+                           do {
+                           skip_type ();
+                           } while (accept (TokenType.COMMA));
+                           expect (TokenType.CLOSE_PARENS);
+               } else {
+                           do {
+                           skip_type ();
+                           } while (accept (TokenType.COMMA));
+                       }
                }
        }
 
+    
        // try to parse type argument list
        List<DataType>? parse_type_argument_list (bool maybe_expression) throws ParseError {
                var begin = get_location ();
                if (accept (TokenType.OF)) {
                        var list = new ArrayList<DataType> ();
-                       do {
-                               switch (current ()) {
-                               case TokenType.VOID:
-                               case TokenType.DYNAMIC:
-                               case TokenType.UNOWNED:
-                               case TokenType.WEAK:
-                               case TokenType.IDENTIFIER:
-                                       var type = parse_type ();
-
-                                       list.add (type);
-                                       break;
-                               default:
-                                       rollback (begin);
-                                       return null;
-                               }
-                       } while (accept (TokenType.COMMA));
+                       var inParens = false;
+
+                       // Optional parens allow multi arg types in function signature: "dict of (int, string)"
+                       // See: https://bugzilla.gnome.org/show_bug.cgi?id=611191
+                       if (accept (TokenType.OPEN_PARENS)) {
+                           inParens = true;
+                       }
+                                               
+                   do {
+                           switch (current ()) {
+                           case TokenType.VOID:
+                           case TokenType.DYNAMIC:
+                           case TokenType.UNOWNED:
+                           case TokenType.WEAK:
+                           case TokenType.IDENTIFIER:
+                                   var type = parse_type ();
+
+                                   list.add (type);
+                                   break;
+                           default:
+                                   rollback (begin);
+                                   return null;
+                           }
+                   } while (accept (TokenType.COMMA));
+                   
+                   if (inParens) {
+                           expect (TokenType.CLOSE_PARENS);
+                       }
 
                        return list;
                }