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-Status: No, score=-3.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY 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 C5D591F4B4 for ; Tue, 12 Jan 2021 18:18:26 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 83232120A66; Wed, 13 Jan 2021 03:17:34 +0900 (JST) Received: from xtrwkhkc.outbound-mail.sendgrid.net (xtrwkhkc.outbound-mail.sendgrid.net [167.89.16.28]) by neon.ruby-lang.org (Postfix) with ESMTPS id 62B86120A4F for ; Wed, 13 Jan 2021 03:17:31 +0900 (JST) Received: by filterdrecv-p3las1-685fdc5bbc-t824x with SMTP id filterdrecv-p3las1-685fdc5bbc-t824x-19-5FFDE7E3-76 2021-01-12 18:18:11.818537423 +0000 UTC m=+2834154.966819575 Received: from herokuapp.com (unknown) by geopod-ismtpd-2-7 (SG) with ESMTP id tWyXf7-uQgWOtq-kjptG7g for ; Tue, 12 Jan 2021 18:18:11.554 +0000 (UTC) Date: Tue, 12 Jan 2021 18:18:11 +0000 (UTC) From: dfranklin@dan-franklin.com Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 77939 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 17530 X-Redmine-Issue-Author: danfranklin X-Redmine-Sender: danfranklin 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?GB6R5YAjXmoR4LKKAn6l3j7uUTuiUOoOHonP22nh9yencXhPGMITpyzo206qBT?= =?us-ascii?Q?i3X99C3tOJCw1nI1cutZkH+V1kHf6mt86hqgqCg?= =?us-ascii?Q?KJsk9Mgk0kFlKl8wu=2FpFNbP1mL=2FEW=2FrLQjVF8B9?= =?us-ascii?Q?n04xCuQ2XgZIDv4hsQXm6Fqoo+KPgz7J25MDe08?= =?us-ascii?Q?c=2FCRBIOBPgAPA76C8hxzLrHA=2FT0UjkUk4lKXsnI?= =?us-ascii?Q?dlEMPTCSSoREBEE7c=3D?= To: ruby-core@ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== X-ML-Name: ruby-core X-Mail-Count: 102036 Subject: [ruby-core:102036] [Ruby master Bug#17530] irb handles << incorrectly with variable as identifier 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 #17530 has been reported by danfranklin (Dan Franklin). ---------------------------------------- Bug #17530: irb handles << incorrectly with variable as identifier https://bugs.ruby-lang.org/issues/17530 * Author: danfranklin (Dan Franklin) * Status: Open * Priority: Normal * ruby -v: 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN ---------------------------------------- If you attempt to start a here-document with an identifier that is also a variable, it is interpreted as an append, which makes sense. That is, > s1 = 'testing' > s2 = 'this' > s2 < adding text here does not work > s1 Gets an expected error: > testcase.rb:4: syntax error, unexpected local variable or method, expecting '(' > adding text here does not work But irb doesn't know this, and gathers input as though it's a here-document: ``` irb(main):001:0' s1 = 'testing' => "testing" irb(main):002:0' s2 = 'this' => "this" irb(main):003:0" s2 <' 2: from /home/centos/.rubies/ruby-3.0.0/bin/irb:23:in `load' 1: from /home/centos/.rubies/ruby-3.0.0/lib/ruby/gems/3.0.0/gems/irb-1.3.0/exe/irb:11:in `' SyntaxError ((irb):4: syntax error, unexpected local variable or method, expecting '(') adding text here does not work ^~~~ irb(main):006:0> ``` Notice the prompt changes on lines 3-5 as though line 3 started a double-quoted here document. irb should realize that line 3 is appending to s2, not starting a here-document. This bug is present in the latest irb: ruby --version ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux] irb --version irb 1.3.0 (2020-12-25) It's an odd edge case, but it confused me when I tried to understand the double meaning of <<, so it seemed worth noting. -- https://bugs.ruby-lang.org/