Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

deprecate fails on methods ending with equal sign

#2431

it is not possible to deprecate methods that end with "=" using ActiveSupport::Deprecation.


class Foo
 attr_accessor bar
 deprecate :bar=
end

this throws the following error:


active_support/deprecation.rb:100:in `deprecate': compile error (SyntaxError)
activesupport/lib/active_support/deprecation.rb:99: syntax error, unexpected ',', expecting '='

this is because Foo.foo=(*bar) is not valid ruby syntax. The fix is to use send instead.

Reported by Michael Siebert · April 6th, 2009 @ 07:03 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Levin Alexander
    Levin Alexander

    attached is an updated patch that adds assert_deprecated { @dtc.f = :foo } to the tests

    April 6th, 2009 @ 07:26 PM

  2. Levin Alexander
    Levin Alexander

    attached is an updated patch that adds assert_deprecated { @dtc.f = :foo } to the tests

    April 6th, 2009 @ 07:27 PM

  3. Levin Alexander
    Levin Alexander

    attached is a patch against current master

    June 25th, 2009 @ 12:04 AM

  4. Levin Alexander
    Levin Alexander
    • Tag changed from active_support, patch to 2.x, 3.0, active_support, patch, small

    June 25th, 2009 @ 12:05 AM

  5. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2.x, 3.0, active_support, patch, small to 2.x, 3.0, active_support, bugmash, patch, small

    August 7th, 2009 @ 02:13 PM

  6. Michael Siebert
    Michael Siebert

    +1

    for levin's patch for 2-3-stable, applies clean and works. we're currently using this patch in production for our own app, so i consider it production-ready

    August 7th, 2009 @ 02:41 PM

  7. Michael Siebert
    Michael Siebert

    +1 for the 2nd patch (for master), too, verified that it works

    August 7th, 2009 @ 02:47 PM

  8. Matt Duncan
    Matt Duncan

    +1 for both patches (2-3-stable and master), verified that both are passing tests and working as expected.

    August 8th, 2009 @ 04:49 AM

  9. Dan Pickett
    Dan Pickett

    verified

    -1 however - a symbol cannot end in equal sign - the deprecate call should really be proper syntax -

    deprecate "bar="

    August 8th, 2009 @ 11:31 PM

  10. Dan Pickett
    Dan Pickett

    sorry - Josevalim corrected me symbols with = at the end are valid > 1.8.6

    August 8th, 2009 @ 11:40 PM

  11. Levin Alexander
    Levin Alexander

    seems they are also valid in ruby 1.8.6:

    system:~$ ruby --version
    ruby 1.8.6 (2007-06-07 patchlevel 36) [x86_64-linux]
    system:~$ ruby -e "p :foo="
    :foo=
    

    August 8th, 2009 @ 11:57 PM

  12. Nick Quaranto
    Nick Quaranto

    +1, both patches look fine to me and activesupport's tests are passing.

    August 9th, 2009 @ 12:08 AM

  13. Kieran P
    Kieran P

    +1 for both 2-3-stable and master patches applying cleanly.

    August 9th, 2009 @ 02:01 AM

  14. Rizwan Reza
    Rizwan Reza
    • Tag changed from 2.x, 3.0, active_support, bugmash, patch, small to 2.x, 3.0, active_support, bugmash, patch, small, verified

    verified

    +1 The patches work fine.

    August 9th, 2009 @ 02:39 AM

  15. José Valim
    José Valim
    • State changed from new to resolved
    • Tag changed from 2.x, 3.0, active_support, bugmash, patch, small, verified to 2.x, 3.0, active_support, patch, small, verified

    August 9th, 2009 @ 03:59 PM

  16. Repository
  17. Repository