From: nobu@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95356] [Ruby master Bug#13249] Access modifiers don't have an effect inside class methods in Ruby >= 2.3
Date: Wed, 16 Oct 2019 07:06:20 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-82064.20191016070619.1fc34f888f3c6f83@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-13249.20170224191346@ruby-lang.org
Issue #13249 has been updated by nobu (Nobuyoshi Nakada).
* Is it necessary that check is placed inside the function `vm_cref_set_visibility`?
What about calling a separate function where `check_method` flag is 1?
* `rb_frame_callee` returns the called name, that may be an aliased name.
Is it intentional?
----------------------------------------
Bug #13249: Access modifiers don't have an effect inside class methods in Ruby >= 2.3
https://bugs.ruby-lang.org/issues/13249#change-82064
* Author: abotalov (Andrei Botalov)
* Status: Assigned
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version:
* ruby -v: 2.3.0, 2.4.0
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Simple example:
~~~ ruby
class C
def self.foo
private
def bar
end
end
end
C.foo
C.new.bar
~~~
This code runs fine on Ruby 2.3 and Ruby 2.4. It raises NoMethodError on Ruby 2.2 and prior versions.
I would expect an error to be raised.
Here is some code that actually uses private access modifier inside a class method - https://github.com/evolve75/RubyTree/blob/db48c35b0a3b96e4da473b095cc00e454d8a9996/lib/tree/utils/camel_case_method_handler.rb#L60
By the way, this code raises an error as expected on Ruby 2.3 and Ruby 2.4:
~~~ ruby
class C
def self.foo
private def bar
end
end
end
C.foo
C.new.bar # NoMethodError: private method `bar' called
~~~
---Files--------------------------------
warn-scope-visibility-in-method-13249.patch (4.18 KB)
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2019-10-16 7:06 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-13249.20170224191346@ruby-lang.org>
2017-02-24 19:13 ` [ruby-core:79751] [Ruby trunk Bug#13249] Access modifiers don't have an effect inside class methods in Ruby >= 2.3 botalov.andrey
2017-02-24 19:34 ` [ruby-core:79752] " botalov.andrey
2017-02-24 19:35 ` [ruby-core:79753] " botalov.andrey
2017-02-24 23:20 ` [ruby-core:79758] " nobu
2017-02-25 7:11 ` [ruby-core:79770] " botalov.andrey
2017-02-25 19:18 ` [ruby-core:79774] " shevegen
2017-02-26 11:41 ` [ruby-core:79787] " botalov.andrey
2017-04-18 4:38 ` [ruby-core:80756] [Ruby trunk Bug#13249][Assigned] " shyouhei
2017-05-19 7:34 ` [ruby-core:81261] [Ruby trunk Bug#13249] " ko1
2019-08-25 0:23 ` [ruby-core:94539] [Ruby master " merch-redmine
2019-10-16 5:26 ` [ruby-core:95351] " mame
2019-10-16 7:06 ` nobu [this message]
2019-10-16 19:10 ` [ruby-core:95372] " merch-redmine
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-82064.20191016070619.1fc34f888f3c6f83@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).