Hi,

At Thu, 14 Nov 2002 06:40:59 +0900,
Rich Kilmer wrote:
> Is is possible to only print the first occurance of a warning of a
> depricated usage of Ruby methods instead of all of them.  Its quite
> painful when you get thousands of "don't use type...use class" errors
> because RACC compiled #type requests into the parser.  I know RACC is
> updated, but the parser that I have is from a third party who has not
> yet updated.

Not impossible, but I'm not sure it's desirable.


Index: error.c =================================================================== RCS file: /cvs/ruby/src/ruby/error.c,v retrieving revision 1.51 diff -u -2 -p -INT -I_WIN32 -r1.51 error.c --- error.c 3 Nov 2002 11:04:16 -0000 1.51 +++ error.c 13 Nov 2002 23:46:11 -0000 @@ -1106,4 +1106,29 @@ err_append(s) fputs("\n", stderr); fflush(stderr); + } +} + +#include "node.h" + +void +rb_deprecated(old, new, now) + const char *old, *new; + int now; +{ + const char *klass; + NODE *node; + + if (!now && !RTEST(ruby_verbose)) return; + klass = rb_class2name(ruby_frame->last_class); + rb_warn("%s#%s %s deprecated; use %s#%s", klass, old, + now ? "is" : "will be", klass, new); + node = ruby_frame->node; + switch (nd_type(node)) { + case NODE_CALL: + case NODE_FCALL: + case NODE_VCALL: + if (node->nd_mid == rb_intern(old)) { + node->nd_mid = rb_intern(new); + } } } Index: object.c =================================================================== RCS file: /cvs/ruby/src/ruby/object.c,v retrieving revision 1.94 diff -u -2 -p -INT -I_WIN32 -r1.94 object.c --- object.c 3 Nov 2002 11:04:17 -0000 1.94 +++ object.c 13 Nov 2002 23:32:19 -0000 @@ -96,5 +96,5 @@ rb_obj_type(obj) VALUE obj; { - rb_warn("Object#type is deprecated; use Object#class"); + rb_deprecated("type", "class", 1); return rb_class_real(CLASS_OF(obj)); }
-- Nobu Nakada