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.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,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 10A2E1F45F for ; Sun, 5 May 2019 04:28:36 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 64C3A12099D; Sun, 5 May 2019 13:28:31 +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 DF104120933 for ; Sun, 5 May 2019 13:28:28 +0900 (JST) Received: by filter0099p3las1.sendgrid.net with SMTP id filter0099p3las1-22692-5CCE666D-9 2019-05-05 04:28:29.474029697 +0000 UTC m=+807203.921675691 Received: from herokuapp.com (unknown [54.80.106.145]) by ismtpd0032p1iad2.sendgrid.net (SG) with ESMTP id 5yJn3cTERTmtffK2jUWZjw for ; Sun, 05 May 2019 04:28:29.226 +0000 (UTC) Date: Sun, 05 May 2019 04:28:29 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 68025 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15789 X-Redmine-Issue-Author: ibylich X-Redmine-Sender: jeremyevans0 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?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIZZAgzFujPM=2FM=2F=2FFMv7JlURypaqs42ZcCaxf0e?= =?us-ascii?Q?YGTsNhbByJeA4zGYQxQ27dzhg6rMuWuOVTxbA5T?= =?us-ascii?Q?aziHbx1sgptGlq19od+HHeovnYyvNetavPV5NDQ?= =?us-ascii?Q?ZS30f0WPlq+5XsNA+gBQ053cuclG0ximZkA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 92542 Subject: [ruby-core:92542] [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 jeremyevans0 (Jeremy Evans). File fix-numbered-parameter-in-optarg-default-value.patch added Attached is a one-line patch that fixes this issue, hopefully without causing additional issues: ```ruby m(a = ->{@1}); a end m.call(1) # => 1 m2 = ->(a = ->{@1}) {a} m2.call.call(2) # => 2 m3 = ->(a: ->{@1}) {a} m3.call.call(3) # => 3 def m(a = @1); a end # SyntaxError ((irb):1: numbered parameter outside block m2 = ->(a = @1) {a} # SyntaxError ((irb):1: ordinary parameter is defined) ``` ---------------------------------------- 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-77901 * 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) -- https://bugs.ruby-lang.org/