[feature:trunk] warning when Kernel#p is used


#1

e$B1sF#$G$9!#e(B

Kernel#p e$B$OHs>o$KJXMx$G$9$,!"%G%P%C%08e$Ke(B p
e$B$N8F$S=P$7$r$9$Y$F>C$;$?$+e(B
e$BIT0B$K$J$k$3$H$,$"$j$^$9!#e(B
p
e$B$H$$$&L>A0$O;H$&$H$-$OHs>o$KJXMx$G$9$,!";DG0$J$,$i8!:w$9$k$K$OHs>o$Ke(B
e$BITJX$G$9!#C18l6h@Z$j$G8!:w$G$-$J$$%(%G%#%?$@$H8!:w$O8B$j$J$/:$Fq$G$9$7!“e(B
e$BC18l6h@Z$j$G8!:w$G$-$k%(%G%#%?$G$”$C$F$b!"e(B

  • p e$B$H$$$&JQ?t$de(B attr e$B$r;H$C$F$$$k>l9ge(B
  • rdoc e$BCf$N%5%s%W%k%3!<%I$H$7$Fe(B p e$B$r;H$C$F$$$k>l9ge(B
  • html e$BCGJR$Ne(B

    e$B$de(B sprint e$B$Ne(B %p
    e$B$J$I$,J8;zNs%j%F%i%kCf$K$"$k>l9ge(B

e$B$J$I!"e(Bfalse positive e$B$,$H$F$bB?$$$G$9!#e(B
p e$B$r:FDj5A$7$F=PNO$r;_$a$l$Pe(B p
e$B$N8F$S=P$7$,;D$C$F$b<B32$O$J$/$;$^$9$,!"e(B
e$BM>7W$J%3!<%I$,;D$k$N$O5$;}$A0-$$$G$9$7!“8e$G$[$+$N%G%P%C%0$r$9$k$H$-$Ke(B
e$B<YKb$K$J$k62$l$b$”$j$^$9!#e(B

e$B$=$3$G!“e(B$DEBUG = true e$B$N>l9g$Ke(B p
e$B$r4X?t8F$S=P$7$7$F$$$k2U=j$,$”$C$?$ie(B
e$B7Y9p$9$k$3$H$rDs0F$7$^$9!#e(B

e$BDL>o;~$O2?$b8@$o$J$$e(B

$ ruby19 -e ‘p :debug’
:debug

-d e$B$r$D$1$k$H7Y9p$9$ke(B

$ ruby19 -d -e ‘p :debug’
-e:1: warning: Kernel#p is used
:debug

e$B%Q!<%5$G%A%’%C%/$9$k$N$G<B9T$5$l$J$$>l9g$G$b8!=P$G$-$ke(B

$ ruby19 -d -e ‘p :debug if rand > 0.999’
-e:1: warning: Kernel#p is used

e$B4X?t8F$S=P$7$G$J$1$l$P7Y9p$7$J$$e(B

$ ruby19 -d -e ‘s = Struct.new(:p); p = s.new; p.p = “

”; puts p.p’

e$B$b$A$m$s!“e(Beval e$B$5$l$kJ8;zNsCf$Ne(B p
e$B$N8F$S=P$7$O<B9T$7$J$$$H8!=P$G$-$J$$e(B
e$B$N$G40`z$G$O$J$$$G$9$,!”$=$l$G$bB?$/$N>l9g$O%+%P!<$G$-$k$H;W$$$^$9!#e(B

e$BLdBjE@$Oe(B

  • p e$B$H$$$&L>A0$N%a%=%C%I$@$1FCJL07$$$G7Y9p$5$l$k$N$,5$;}$A0-$$e(B
  • e$B8_49@-e(B

e$B$/$i$$$+$H;W$$$^$9$,!"e(B$DEBUG = true
e$B$J$iK\HV4D6-$G$J$$$N$G!"8D?ME*$K$Oe(B
e$B5vMFHO0O$+$J$H;W$$$^$7$?!#$I$&$G$7$g$&$+!#e(B

Index: id.c

— id.c (revision 22892)
+++ id.c (working copy)
@@ -47,4 +47,5 @@
REGISTER_SYMID(idSend, “send”);
REGISTER_SYMID(id__send__, “send”);
REGISTER_SYMID(idInitialize, “initialize”);

  • REGISTER_SYMID(idP, “p”);
    }
    Index: parse.y
    ===================================================================
    — parse.y (revision 22892)
    +++ parse.y (working copy)
    @@ -1257,6 +1257,9 @@
    command : operation command_args %prec tLOWEST
    {
    /%%%/
  •  if ($1 == idP && RTEST(ruby_debug)) {
    
  •      rb_warning0("Kernel#p is used");
    
  •  }
     $$ = NEW_FCALL($1, $2);
     fixpos($$, $2);
       /*%
    

@@ -3525,6 +3528,9 @@
method_call : operation paren_args
{
/%%%/

  •  if ($1 == idP && RTEST(ruby_debug)) {
    
  •      rb_warning0("Kernel#p is used");
    
  •  }
     $$ = NEW_FCALL($1, $2);
     fixpos($$, $2);
       /*%
    

Index: id.h

— id.h (revision 22892)
+++ id.h (working copy)
@@ -99,6 +99,7 @@
tSend,
t__send__,
tInitialize,

  • tP,
    #if SUPPORT_JOKE
    tBitblt,
    tAnswer,
    @@ -118,7 +119,8 @@
    TOKEN2ID(Lambda),
    TOKEN2ID(Send),
    TOKEN2ID(send),
  • TOKEN2ID(Initialize)
  • TOKEN2ID(Initialize),
  • TOKEN2ID§
    };

#ifdef tLAST_TOKEN
Index: template/id.h.tmpl

— template/id.h.tmpl (revision 22892)
+++ template/id.h.tmpl (working copy)
@@ -92,6 +92,7 @@
tSend,
t__send__,
tInitialize,

  • tP,
    #if SUPPORT_JOKE
    tBitblt,
    tAnswer,
    @@ -111,7 +112,8 @@
    TOKEN2ID(Lambda),
    TOKEN2ID(Send),
    TOKEN2ID(send),
  • TOKEN2ID(Initialize)
  • TOKEN2ID(Initialize),
  • TOKEN2ID§
    };

#ifdef tLAST_TOKEN


#2

e$B$3$s$K$A$O!"$J$+$`$ie(B(e$B$&e(B)e$B$G$9!#e(B

In message “[ruby-dev:38153] [feature:trunk] warning when Kernel#p is
used”
on Mar.11,2009 21:29:22, removed_email_address@domain.invalid wrote:

e$BLdBjE@$Oe(B

  • p e$B$H$$$&L>A0$N%a%=%C%I$@$1FCJL07$$$G7Y9p$5$l$k$N$,5$;}$A0-$$e(B
  • e$B8_49@-e(B

e$B$/$i$$$+$H;W$$$^$9$,!"e(B$DEBUG = true e$B$J$iK\HV4D6-$G$J$$$N$G!"8D?ME*$K$Oe(B
e$B5vMFHO0O$+$J$H;W$$$^$7$?!#$I$&$G$7$g$&$+!#e(B

e$B;d$Oe(B

p foo if $DEBUG

e$B$H$$$&%3!<%I$rIQHK$K=q$/$s$G$9$,!"%@%a$J$s$G$7$g$&$+!#e(B
pe$B$r;H$&$N$O%G%P%C%0;~$J$o$1$G$9$+$i!"EvA3e(B$DEBUGe$B$,e(Btruee$B$N;~$K$3e(B
e$B$=e(Bpe$B$KK\Mh$N;E;v$rM>7W$JK832$J$7$G$3$J$7$F$b$i$&$Y$-$@$H;W$$$^e(B
e$B$9!#e(B

e$B%"%$%G%"<+BN$O0-$/$J$$$H;W$$$^$9$,!"%Q!<%5%l%Y%k$G%A%’%C%/$9e(B
e$B$k$N$G$"$l$P!"e(Bsyntax check
(-c)e$B$J$I$G$R$C$+$1$k$N$,$h$$$N$G$Oe(B
e$B$J$$$+$H;W$$$^$9!#e(B

e$B$=$l$G$O!#e(B


#3

e$B!!$5$5$@$G$9!%e(B

Yusuke ENDOH wrote::

  • e$B?7$7$$%*%W%7%g%s$rDI2C$9$ke(B
  • e$B4D6-JQ?t$G;XDj$9$ke(B
  • RubyVM.warn_p = true e$B$H$$$&e(B warn-p.rb e$B$re(B require e$B$9$ke(B

e$B$J$I!"FC$K$3$@$o$j$O$J$$$G$9!#e(B(e$B:G8e$N$OL>A00J30$o$j$H$$$$$+$b!)e(B)

e$B!!e(Bwarn-p.rb e$B$r;H$$$?$$?M$,e(B require
e$B$9$k!$$@$HB-$j$J$$$G$9$+$M!%$G!$e(Bp e$B$re(B
e$B:FDj5A$7$F$7$^$($P!%e(B

e$B%"%$%G%"<+BN$O0-$/$J$$$H;W$$$^$9$,!"%Q!<%5%l%Y%k$G%A%’%C%/$9e(B
e$B$k$N$G$"$l$P!"e(Bsyntax check (-c)e$B$J$I$G$R$C$+$1$k$N$,$h$$$N$G$Oe(B
e$B$J$$$+$H;W$$$^$9!#e(B

e$B$=$l$G$b$$$$$H;W$$$^$9!#e(B

e$B!!%Q!<%5%l%Y%k$G$OFq$7$$$s$8$c$J$$$G$9$+$M!%e(B


#4

e$B1sF#$G$9!#e(B

2009/03/11 23:48 SASADA Koichi removed_email_address@domain.invalid:

e$B!!e(Bwarn-p.rb e$B$r;H$$$?$$?M$,e(B require e$B$9$k!$$@$HB-$j$J$$$G$9$+$M!%$G!$e(Bp e$B$re(B
e$B:FDj5A$7$F$7$^$($P!%e(B

e$B$($($H!"Ds0F$N%]%$%s%H$O!Ve(Bp
e$B$H$$$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$^$9!#:G=i$N%a!<%k$K%Q%C%A$,$"$j$^$9!#e(B


#5

e$B1sF#$G$9!#e(B

2009/03/11 21:50 U.Nakamura removed_email_address@domain.invalid:

e$B;d$Oe(B

p foo if $DEBUG

e$B$H$$$&%3!<%I$rIQHK$K=q$/$s$G$9$,!"%@%a$J$s$G$7$g$&$+!#e(B

p e$B$H$$$&$9$P$i$7$$L>A0$NMxE@$,A_$->C$($k$N$G%@%a$G$9!#e(B

e$B$5$i$K!"$"$k2U=j$N%G%P%C%0Cf$Ke(B p foo if $DEBUG
e$B$H=q$$$F;D$7$Fe(B
e$B$7$^$&$H!"JL$N2U=j$r%G%P%C%0$9$k$?$a$Ke(B p bar if $DEBUG
e$B$H$7$?$ie(B
e$B=PNO$,:.$6$C$F$o$1$o$+$i$J$/$J$j$^$9!#e(B

pe$B$r;H$&$N$O%G%P%C%0;~$J$o$1$G$9$+$i!"EvA3e(B$DEBUGe$B$,e(Btruee$B$N;~$K$3e(B
e$B$=e(Bpe$B$KK\Mh$N;E;v$rM>7W$JK832$J$7$G$3$J$7$F$b$i$&$Y$-$@$H;W$$$^e(B
e$B$9!#e(B

e$B3N$+$Ke(B $DEBUG e$B$r;H$&$N$O$$$^$$$A$G$9$M!#e(B
p e$B$N8!=P5!G=$NM-8z!&L58z$r@Z$jBX$($i$l$l$P$J$s$G$b$$$$$N$G!"e(B

  • e$B?7$7$$%*%W%7%g%s$rDI2C$9$ke(B
  • e$B4D6-JQ?t$G;XDj$9$ke(B
  • RubyVM.warn_p = true e$B$H$$$&e(B warn-p.rb e$B$re(B require
    e$B$9$ke(B

e$B$J$I!"FC$K$3$@$o$j$O$J$$$G$9!#e(B(e$B:G8e$N$OL>A00J30$o$j$H$$$$$+$b!)e(B)

e$B%"%$%G%"<+BN$O0-$/$J$$$H;W$$$^$9$,!"%Q!<%5%l%Y%k$G%A%’%C%/$9e(B
e$B$k$N$G$"$l$P!"e(Bsyntax check (-c)e$B$J$I$G$R$C$+$1$k$N$,$h$$$N$G$Oe(B
e$B$J$$$+$H;W$$$^$9!#e(B

e$B$=$l$G$b$$$$$H;W$$$^$9!#e(B


#6

2010/3/26 Yusuke E. removed_email_address@domain.invalid:

e$B<XB-$G$9$,!“B>$K$b4JC1$Je(B lint e$B$r<BAu$9$k$J$ILLGr$=$&!#e(B
e$B%m!<%+%kJQ?t$OA4It>.J8;z$Ge(B _ e$B6h@Z$j$H$+!”%/%i%9L>$Oe(B Camel Case
e$B$H$+!#0l9Te(B 80 e$B7e$H$+!“e(B1 e$B%a%=%C%I$N9T?t$Oe(B 24 e$B9T$^$G$H$+!#0[O@$Oe(B
e$B$”$j$=$&!#e(B

rippere$B$r;H$C$?e(Blinte$B<BAu$NNc$r8x3+$9$k$[$&$,!“HFMQ@-$,$”$C$FJ@32$,>/$J$/!"$=$N8e$KB3$/e(Bcheckere$B$d$ie(Bindente$B$d$i$NAC$K$J$j$=$&$G$9$M!#e(B


#7

e$B%A%1%C%He(B #1269 e$B$,99?7$5$l$^$7$?!#e(B (by Yusuke E.)

Target version 1.9.xe$B$K%;%C%He(B

e$B1sF#$G$9!#e(B

2009e$BG/e(B3e$B7ne(B11e$BF|e(B21:31 Yusuke ENDOH removed_email_address@domain.invalid:

e$B$J$I!"e(Bfalse positive e$B$,$H$F$bB?$$$G$9!#e(B
p e$B$r:FDj5A$7$F=PNO$r;_$a$l$Pe(B p e$B$N8F$S=P$7$,;D$C$F$b<B32$O$J$/$;$^$9$,!"e(B
e$BM>7W$J%3!<%I$,;D$k$N$O5$;}$A0-$$$G$9$7!“8e$G$[$+$N%G%P%C%0$r$9$k$H$-$Ke(B
e$B<YKb$K$J$k62$l$b$”$j$^$9!#e(B

e$B$=$3$G!“e(B$DEBUG = true e$B$N>l9g$Ke(B p e$B$r4X?t8F$S=P$7$7$F$$$k2U=j$,$”$C$?$ie(B
e$B7Y9p$9$k$3$H$rDs0F$7$^$9!#e(B

e$B$H$$$&Ds0F$re(B 1 e$BG/A0$K$7$^$7$?$,!"e(B$DEBUG
e$B$H$$$&%$%s%?!<%U%’%$%9e(B
e$B$K%1%A$,$D$$$F$$$^$7$?!#e(B

2009e$BG/e(B3e$B7ne(B11e$BF|e(B21:50 U.Nakamura removed_email_address@domain.invalid:

e$B%"%$%G%"<+BN$O0-$/$J$$$H;W$$$^$9$,!"%Q!<%5%l%Y%k$G%A%’%C%/$9e(B
e$B$k$N$G$"$l$P!"e(Bsyntax check (-c)e$B$J$I$G$R$C$+$1$k$N$,$h$$$N$G$Oe(B
e$B$J$$$+$H;W$$$^$9!#e(B

[ruby-dev:40768] e$B$r8+$F;W$$$D$$$?$N$G$9$,!"e(Bruby -c -v
e$B$N;~$@$1e(B
e$B7Y9p$7$F$/$l$k$H$$$$$s$8$c$J$$$+$H;W$$$^$7$?!#e(B

e$B<XB-$G$9$,!“B>$K$b4JC1$Je(B lint e$B$r<BAu$9$k$J$ILLGr$=$&!#e(B
e$B%m!<%+%kJQ?t$OA4It>.J8;z$Ge(B _ e$B6h@Z$j$H$+!”%/%i%9L>$Oe(B Camel
Case
e$B$H$+!#0l9Te(B 80 e$B7e$H$+!“e(B1 e$B%a%=%C%I$N9T?t$Oe(B 24
e$B9T$^$G$H$+!#0[O@$Oe(B
e$B$”$j$=$&!#e(B


Yusuke ENDOH removed_email_address@domain.invalid

http://redmine.ruby-lang.org/issues/show/1269