ArgumentError points to wrong line

Run the attached Ruby file.

The line mentioned for ArgumentError is 14, but the mistake is in line 17.

Ruby 1.6.5, 1.6.7 and 1.7.2 tested.

Bye,
Kero.

±-- Kero ------------------------------ kero@chello.nl —+

Don’t split your mentality without thinking twice |
Proud like a God – Guano Apes |
±-- M38c ---------- http://httpd.chello.nl/k.vangelder —+

misnumber-report.rb (443 Bytes)

Kero van Gelder kero@a26074.upc-a.chello.nl wrote in message news:20020628200654.GA1647@chmeee

I think ArgumentError will point to the beginning of a method call if
the error is w/in a method call. ie. you’d see similar behavior if
the code was something like

packages.set(
Package.new(“ruby-dev”, “lib”, “extra”),
Package.new(“ruby-tk”, “lib”, “extra”),
Package.new(“ruby-doc”, “man”, “extra”),
Package.new(“ruby”, “interpreter”)
)

In general the parser’s error messages could use some work, but by the
time you feel adventurous enough to look into it you’ve gotten used to
them :slight_smile:

A friend of mine, Tom Clarke was working on fixing some of these – he
thought “NameError” in particular was a confusing message.

~ Patrick

Hi,

···

At Sat, 29 Jun 2002 05:06:34 +0900, Kero van Gelder wrote:

The line mentioned for ArgumentError is 14, but the mistake is in line 17.

Try this patch.

Index: eval.c

RCS file: /cvs/ruby/src/ruby/eval.c,v
retrieving revision 1.303
diff -u -2 -p -r1.303 eval.c
— eval.c 24 Jun 2002 07:20:42 -0000 1.303
+++ eval.c 30 Jun 2002 16:57:24 -0000
@@ -1860,4 +1860,5 @@ is_defined(self, node, buf)
int call = nd_type(node)== NODE_CALL;

  •   ruby_sourceline = nd_line(node);
      val = CLASS_OF(val);
      if (call) {
    

@@ -2719,4 +2720,5 @@ rb_eval(self, n)
END_CALLARGS;

  •   ruby_sourceline = nd_line(node);
      result = rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0);
    

    }
    @@ -2732,4 +2734,5 @@ rb_eval(self, n)
    END_CALLARGS;

  •   ruby_sourceline = nd_line(node);
      result = rb_call(CLASS_OF(self),self,node->nd_mid,argc,argv,1);
    

    }
    @@ -2737,4 +2740,5 @@ rb_eval(self, n)

     case NODE_VCALL:
    
  • ruby_sourceline = nd_line(node);
    result = rb_call(CLASS_OF(self),self,node->nd_mid,0,0,2);
    break;


Nobu Nakada