From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-2.6 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,SPF_PASS, T_DKIM_INVALID shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id C5AB6202A5 for ; Mon, 25 Sep 2017 18:15:45 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5F2CF1209F6; Tue, 26 Sep 2017 03:15:42 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id C81BF1209F5 for ; Tue, 26 Sep 2017 03:15:39 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=sDW+cBXYPLA843qCU9YVlTlozrw=; b=ATPdOtRSHHxZnWXt7l 77SOrgh5me7+JnBEMgoyfrX6VNbnp3KiWVQIfUejWC2FObBUwHe60R6klRkpaYRs ItlTXgxpbMd+TPnaZf9Hk3KAYF91qDTWH3cd0Yp8EG9SsOkH0TiGLwdtJc9drRJf bMFt2zbNfhM0YVAO7WcK0kVyE= Received: by filter0028p3mdw1.sendgrid.net with SMTP id filter0028p3mdw1-11319-59C947C7-45 2017-09-25 18:15:35.698302683 +0000 UTC Received: from herokuapp.com (ec2-54-159-30-54.compute-1.amazonaws.com [54.159.30.54]) by ismtpd0020p1iad2.sendgrid.net (SG) with ESMTP id zbEWRmvYTnyTVIAULyUJew for ; Mon, 25 Sep 2017 18:15:35.433 +0000 (UTC) Date: Mon, 25 Sep 2017 18:15:36 +0000 (UTC) From: shevegen@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 58105 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 13939 X-Redmine-Issue-Author: danielpclark X-Redmine-Sender: shevegen X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS53unavXMLlUgNHlMCjNWsM1GKog6tNUG1+Cf XAzkrUXjnKr9ZzSOlPdbPENwELxP8huEKSQ4zWLPK6+BrMl2emIVNU+KqmY8n1zJCI3ghljlfTg48D F2ytS26v0x6fSCaCgnmeFzz+Usi0U6gC7ouT1O4QszPLmNxGwj7Y5qCUaA== X-ML-Name: ruby-core X-Mail-Count: 83004 Subject: [ruby-core:83004] [Ruby trunk Bug#13939] Ruby 2.4.2 has issue supporting Seattle.rb style for define_method X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #13939 has been updated by shevegen (Robert A. Heiler). Let's ignore the "Seattle.rb style" for the moment because I don't know of such a thing - may well be seattle-duck style. :P But anyway, I agree with you in at the least one point, which is the warning message: > Anyone who tries to load my 'read_source' gem will get a failure message > in require without explaining the specific area of code. Perhaps the error message could be more indicative of the error or what the exact problem is or how to solve it. I understand that the () provide additional information that is in some way useful to the parser, or whatever is responsible, so perhaps the message above could be changed somewhat. I guess ruby core prefers short messages when possible (aka "syntax error, unexpected '}'") but this is indeed not always extremely helpful. With more recent changes such as the did-you-mean-gem, but also some other discussions about better and more fine-tuned control over warnings/error messages, that may be helpul. To the issue about differential parsing, that is actually indeed strange. Even more surprising is that I actually thought that: define_method(:some_method_name) { "asdf" } Is the only way to use define_method() :D I think I used that always ... It reminds me a bit of: get '/' do play_intro_music end versus get '/' { play_intro_music } # which does not work versus get('/') { play_intro_music } which works. I always thought that in some cases the ruby parse needs the (). I'd love to be able to make them optional in the second case. Oddly enough, for method DEFINITIONS, I always use () when there are arguments, so "def foo(bar)" is what I prefer over "def foo bar". This is more an aside though, it is strange that this changed. By the way your last example does not work as-is :D define_method :johny, instance_method(:apple) NoMethodError: undefined method `instance_method' for main:Object Sorry for nitpicking there, I understand what you mean. I guess it may be because of {} having different meanings in ruby but then again, there was probably some reason unless it was an accident. It's ~3:15 in Tokyo so I guess in a few hours perhaps some from the ruby core team can chime in. I did not even know that we could omit the () there, that was awesome if that was possible. I remember in my code though, that whenever I used define_method(), I always used () ... usually in combination with some *eval* method thing. ---------------------------------------- Bug #13939: Ruby 2.4.2 has issue supporting Seattle.rb style for define_method https://bugs.ruby-lang.org/issues/13939#change-66913 * Author: danielpclark (Daniel P. Clark) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux] * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- In Ruby 2.3 & 2.4.0 you can do this ~~~ruby define_method :some_method_name { "asdf" } ~~~ As of my trying 2.4.2 this is no longer supported. Anyone who tries to load my 'read_source' gem will get a failure message in require without explaining the specific area of code. ~~~ SyntaxError: /home/danielpclark/dev/read_source/test/support/example.rb:18: syntax error, unexpected '{', expecting keyword_end ethod :also_attr_method_name { "asdf" } ^ /home/danielpclark/dev/read_source/test/support/example.rb:18: syntax error, unexpected '}', expecting keyword_end so_attr_method_name { "asdf" } ^ from (irb):2:in `require_relative' from (irb):2 from /usr/share/rvm/rubies/ruby-2.4.2/bin/irb:11:in `
' ~~~ To fix my gem for Ruby 2.4.2 I now have to wrap the method name in parenthesis `()` ~~~ruby define_method(:some_method_name) { "asdf" } ~~~ And that will work. But I find this odd as the following will still work in 2.4.2: ~~~ruby define_method :johny, instance_method(:apple) ~~~ Which is still Seattle.rb style. -- https://bugs.ruby-lang.org/