From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id A4CD21F45F for ; Sun, 5 May 2019 07:44:58 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 3986C1209E5; Sun, 5 May 2019 16:44:53 +0900 (JST) Received: from o1678916x28.outbound-mail.sendgrid.net (o1678916x28.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1B46E12091B for ; Sun, 5 May 2019 16:44:49 +0900 (JST) Received: by filter0067p3las1.sendgrid.net with SMTP id filter0067p3las1-18830-5CCE9472-A 2019-05-05 07:44:50.738577095 +0000 UTC m=+818173.114239117 Received: from herokuapp.com (unknown [54.80.106.145]) by ismtpd0049p1mdw1.sendgrid.net (SG) with ESMTP id _3KnWasiSe6dT6lpgQ9NuA for ; Sun, 05 May 2019 07:44:50.628 +0000 (UTC) Date: Sun, 05 May 2019 07:44:50 +0000 (UTC) From: nobu@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68030 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15789 X-Redmine-Issue-Author: ibylich X-Redmine-Sender: nobu 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: =?us-ascii?Q?q8Dly+pU2+3ektTtZVXgZtbJPXwqo7p86jCsvYTW4BzL7r28yrgPJKVyxio0MA?= =?us-ascii?Q?znOvw=2FgZ4fY7X2jT8rzLbGOvTJT4Sf1rRVZ4XXV?= =?us-ascii?Q?SZbaVfkTUngiIIiTQqTdzipidbj2VytQGrfXYlO?= =?us-ascii?Q?4TsZba2JPwISf2LHWXP=2FMES12=2FxAjwMtfliQ9fe?= =?us-ascii?Q?P2sVcLa=2FHdeDi1WbNCyEXzjYm62HW1K4TJg=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92547 Subject: [ruby-core:92547] [Ruby trunk Bug#15789] Parse error when numbered parameter is used in a lambda that is a default value of other optarg 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 #15789 has been updated by nobu (Nobuyoshi Nakada). jeremyevans0 (Jeremy Evans) wrote: > Attached is a one-line patch that fixes this issue, hopefully without causing additional issues: Thank you, committed the patch. > ```ruby > m2 = ->(a = @1) {a} > # SyntaxError ((irb):1: ordinary parameter is defined) > ``` This should be the "outside block" error, I think. ---------------------------------------- Bug #15789: Parse error when numbered parameter is used in a lambda that is a default value of other optarg https://bugs.ruby-lang.org/issues/15789#change-77908 * Author: ibylich (Ilya Bylich) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.7.0dev (2019-04-24 trunk cf930985da) [x86_64-darwin18] * Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN ---------------------------------------- Sorry if the name of the ticket is not desccriptive While working on backporting these commits into a parser gem: https://github.com/ruby/ruby/commit/6ca9e7cc0785c33f6d382176dbd79d6c91db72fe https://github.com/ruby/ruby/commit/ae07b66aaa092c59ac9d544c9b582712290dc357 ... I've found a weird case that throws a SyntaxError: ``` ruby > def m(a = ->{@1}); end SyntaxError ((irb):10: ordinary parameter is defined) def m(a = ->{@1}); end ^~ ``` And same errors gets thrown when I pass a lambda with numparams to lambda optarg: ``` ruby > ->(optarg = ->{@1}) {} SyntaxError ((irb):1: ordinary parameter is defined) ->(optarg = ->{@1}) {} ^~ ``` I guess the reason for that is that p->max_numparam should be organized as a stack, not a plain shared value. ---Files-------------------------------- fix-numbered-parameter-in-optarg-default-value.patch (546 Bytes) fix-numbered-parameter-in-optarg-default-value-v2.patch (1.42 KB) -- https://bugs.ruby-lang.org/