]> granicus.if.org Git - jq/commitdiff
Multi-arity needs better errors (fix #438)
authorNicolas Williams <nico@cryptonector.com>
Wed, 2 Jul 2014 07:18:10 +0000 (02:18 -0500)
committerNicolas Williams <nico@cryptonector.com>
Wed, 2 Jul 2014 07:18:10 +0000 (02:18 -0500)
compile.c

index d5a1559a0c1775f3955b49db492b4efc6a3de364..597fa6f1456bb2be296475c19b210f96d2a6bf21 100644 (file)
--- a/compile.c
+++ b/compile.c
@@ -481,7 +481,7 @@ static int expand_call_arglist(struct locfile* locations, block* b) {
   for (inst* curr; (curr = block_take(b));) {
     if (opcode_describe(curr->op)->flags & OP_HAS_BINDING) {
       if (!curr->bound_by) {
-        locfile_locate(locations, curr->source, "error: %s is not defined", curr->symbol);
+        locfile_locate(locations, curr->source, "error: %s/%d is not defined", curr->symbol, block_count_actuals(curr->arglist));
         errors++;
         // don't process this instruction if it's not well-defined
         ret = BLOCK(ret, inst_block(curr));
@@ -546,14 +546,7 @@ static int expand_call_arglist(struct locfile* locations, block* b) {
       }
       }
 
-      if (actual_args != desired_args) {
-        locfile_locate(locations, curr->source, 
-                       "error: %s arguments to %s (expected %d but got %d)",
-                       actual_args > desired_args ? "too many" : "too few",
-                       curr->symbol, desired_args, actual_args);
-        errors++;
-      }
-
+      assert(actual_args == desired_args); // because now handle this above
     }
     ret = BLOCK(ret, prelude, inst_block(curr));
   }