From: Austin Ziegler Date: 2020-12-04T12:34:00-05:00 Subject: [ruby-core:101244] Re: [Ruby master Feature#17055] Allow suppressing uninitialized instance variable and method redefined verbose mode warnings --===============0043384309== Content-Type: multipart/alternative; boundary="000000000000ca3d9605b5a6e254" --000000000000ca3d9605b5a6e254 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks. It=E2=80=99s only partially unrelated, because while it would be gr= eat for RDoc to do the right thing (always treat `foo/foo=3D` method pairs as if th= ey were attribute writers), the `undef` was done *specifically* to avoid the =E2=80=9Credefining a method=E2=80=9D warning. -a On Thu, Dec 3, 2020 at 6:05 PM Jeremy Evans wrote: > On 12/03 05:44, Austin Ziegler wrote: > > What does this mean? > > > > > Considering that you can alias a method to itself to avoid the warnin= g, > > and therefore do not need to remove the method first (which would cause= a > > race condition), I am dropping my request to add > > `expected_redefined_method?(method_name)`. > > As shown by Urabe-san: > > ```ruby > def foo > end > > # This avoids the redefinition warning > alias foo foo > > # This would normally result in a redefinition warning in verbose mode, > # if not for the alias above. > def foo > end > ``` > > > I have code that I???ve written to get around some rdoc silliness that > does: > > > > # rdoc documentation for foo. > > attr_writer :foo > > undef :foo=3D > > def foo=3D(x) #:nodoc: > > # specialized foo assignment code > > end > > > > If I didn???t do this, RDoc documents both the attribute and the `foo= =3D` > > method (or it did the last time I checked) even though all I want > > documented is the attribute for readability. How would I make it so tha= t > I > > don???t need to do `undef :foo=3D` here, as that has been one thing tha= t > has > > failed this code (_hard_) with both type analyzers for Ruby. > > This seems to be an unrelated issue. I would avoid the attr_writer and > the undef. If you just want RDoc to mark this as an attribute method > instead of general method, then you may want to submit a pull request to > rdoc to add markup syntax to be able to flag a regular method as an > attribute method. > > Thanks, > Jeremy > > Unsubscribe: > > --=20 Austin Ziegler =E2=80=A2 halostatue@gmail.com =E2=80=A2 austin@halostatue.c= a http://www.halostatue.ca/ =E2=80=A2 http://twitter.com/halostatue --000000000000ca3d9605b5a6e254 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks. It=E2=80=99s only partially unrelated, because whi= le it would be great for RDoc to do the right thing (always treat `foo/foo= =3D` method pairs as if they were attribute writers), the `undef` was done = specifically=C2=A0to avoid the =E2=80=9Credefining a method=E2=80=9D= warning.

-a

<= div dir=3D"ltr" class=3D"gmail_attr">On Thu, Dec 3, 2020 at 6:05 PM Jeremy = Evans <code@jeremyevans.net&= gt; wrote:
On 12/03 05:44, Austin Ziegler wrote:<= br> > What does this mean?
>
> > Considering that you can alias a method to itself to avoid the wa= rning,
> and therefore do not need to remove the method first (which would caus= e a
> race condition), I am dropping my request to add
> `expected_redefined_method?(method_name)`.

As shown by Urabe-san:

```ruby
def foo
end

# This avoids the redefinition warning
alias foo foo

# This would normally result in a redefinition warning in verbose mode,
# if not for the alias above.
def foo
end
```

> I have code that I???ve written to get around some rdoc silliness that= does:
>
>=C2=A0 =C2=A0# rdoc documentation for foo.
>=C2=A0 =C2=A0attr_writer :foo
>=C2=A0 =C2=A0undef :foo=3D
>=C2=A0 =C2=A0def foo=3D(x) #:nodoc:
>=C2=A0 =C2=A0 =C2=A0# specialized foo assignment code
>=C2=A0 =C2=A0end
>
> If I didn???t do this, RDoc documents both the attribute and the `foo= =3D`
> method (or it did the last time I checked) even though all I want
> documented is the attribute for readability. How would I make it so th= at I
> don???t need to do `undef :foo=3D` here, as that has been one thing th= at has
> failed this code (_hard_) with both type analyzers for Ruby.

This seems to be an unrelated issue.=C2=A0 I would avoid the attr_writer an= d
the undef.=C2=A0 If you just want RDoc to mark this as an attribute method<= br> instead of general method, then you may want to submit a pull request to rdoc to add markup syntax to be able to flag a regular method as an
attribute method.

Thanks,
Jeremy

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=3Dunsubscribe= >
<http://lists.ruby-lang.org/cgi-bin/m= ailman/options/ruby-core>


--
--000000000000ca3d9605b5a6e254-- --===============0043384309== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline Unsubscribe: --===============0043384309==--