From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on starla X-Spam-Level: X-Spam-Status: No, score=0.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id A9D211F4CC for ; Wed, 4 Dec 2024 16:16:44 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; unprotected) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=UJvZdmIS; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=caP2UXqa; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1733328972; bh=kv5/Eco+qr5GUg52Dn2jOfuJbg6jBeawUzHcnk1kJG8=; h=Date:References:To:Reply-To:Subject:List-Id:List-Archive: List-Help:List-Owner:List-Post:List-Subscribe:List-Unsubscribe: From:Cc:From; b=UJvZdmISJPUYS3O6FSjxe8qM87Y4rqmPgTZ37/JVs8yZU7UTVcM9YKdJlMrFxshCb 5GQQKbLgft5nAfYWR73B95du75u+Mtgr4hYLFHZDhufrTpdo6G7fS28p+s3Fkclkm4 ota5j1lID7FVRKWP6/tWR3C5M5M7aTLrZPbgrrzs= Received: from nue.mailmanlists.eu (localhost [IPv6:::1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 5C1F144CC6 for ; Wed, 4 Dec 2024 16:16:12 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=pass (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=caP2UXqa; dkim-atps=neutral Received: from s.wrqvtzvf.outbound-mail.sendgrid.net (s.wrqvtzvf.outbound-mail.sendgrid.net [149.72.126.143]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 3038A4385D for ; Wed, 4 Dec 2024 16:16:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc:content-type:from:subject:to; s=s1; bh=yeJSctuh+zydN+fxFiY21r1ifw4X/qfIfy7TXBaCnFA=; b=caP2UXqa1sylJOAqMftVrLiNwDVp3OGe+/wIbl6lfqHW/p4nRvYFhhUwLNACEOGc3kWH RLEv3Z07NCLjVM81ma6u+mNiraH11KxCTKPaQFx1FX6JTbYugNdPqDXIPywaBL86BQqxJ0 NsZCnNzzK9mFAreMkxdpqnYNYZnBbmri9hqFoFS607l2O7+TRvFwQhNkoz7Ko1jRb0DXlh 5JiuaxdlQgQKm3hp0Wlm2/E2Gwhiu1VM3gdMRvnIcPkaT/EDeqxyd/HlNw06eUyskum8sg f6OJM0BG9AOFy4Y1I8cZFpdqCOVexynnX9XX9OSnp0dqLVG26HQKxwHnWFUS0Q5Q== Received: by recvd-84b546689d-ww4vb with SMTP id recvd-84b546689d-ww4vb-1-6750803E-D 2024-12-04 16:15:58.621490205 +0000 UTC m=+1709495.070641162 Received: from herokuapp.com (unknown) by geopod-ismtpd-45 (SG) with ESMTP id omDF_HOYQhuvPB2L-WEy9A for ; Wed, 04 Dec 2024 16:15:58.552 +0000 (UTC) Date: Wed, 04 Dec 2024 16:15:58 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20918 X-Redmine-Issue-Author: mame X-Redmine-Issue-Assignee: Group (prism) X-Redmine-Issue-Priority: Normal X-Redmine-Sender: tenderlovemaking 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-Redmine-MailingListIntegration-Message-Ids: 96779 X-SG-EID: =?us-ascii?Q?u001=2ElWMe69GVkz6xHw8adpMU6eTKSGZqJ7+E1FrjckpA7cvWAPDyDX2cAv9Do?= =?us-ascii?Q?wZtGRg2vsYQLU1U4jx+ljWd9jTs=2FpZn02mllaZG?= =?us-ascii?Q?4g2CkB4nYTDiwdurLu7XptqafP8hLJfbtOjzeyP?= =?us-ascii?Q?fBzvjDlrP+Zpz1xDTKfi3vBdIPj+JIcBKp5XFFp?= =?us-ascii?Q?eeoiQ7ABFOdEdXgqVs3v6m+JSAbN8lPOr1dF3Y4?= =?us-ascii?Q?+Lw8kC80NzQggYLDnAkpm9M4GnuLcBfBOmqnwx7?= =?us-ascii?Q?Igm=2FqhSpSbIU36r6AuNL9krMcw=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: TXNMJW534UIWPTVMH4LX24HBHQUGA2LN X-Message-ID-Hash: TXNMJW534UIWPTVMH4LX24HBHQUGA2LN X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:120103] [Ruby master Bug#20918] Prism error indicates line number of `-e` that does not exist List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "tenderlovemaking (Aaron Patterson) via ruby-core" Cc: "tenderlovemaking (Aaron Patterson)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20918 has been updated by tenderlovemaking (Aaron Patterson). kddnewton (Kevin Newton) wrote in #note-3: > I looked into this this morning, it looks like ruby.c is automatically concatenating a \n onto the -e script here: https://github.com/ruby/ruby/blob/f43585b02c3634ab9a4e54049b08e04ab1a640fd/ruby.c#L1303. Is this desired behavior? I'm not sure if it matters. If you have a script with one line (that has a newline), Prism will report line 2 as the error. ``` [aaron@tc-lan-adapter ~/g/ruby (master)]$ cat x.rb foo( [aaron@tc-lan-adapter ~/g/ruby (master)]$ od -c x.rb 0000000 f o o ( \n 0000005 [aaron@tc-lan-adapter ~/g/ruby (master)]$ wc -l x.rb 1 x.rb [aaron@tc-lan-adapter ~/g/ruby (master)]$ ./miniruby x.rb x.rb: x.rb:2: syntax error found (SyntaxError) 1 | foo( > 2 | | ^ unexpected end-of-input; expected a `)` to close the arguments [aaron@tc-lan-adapter ~/g/ruby (master)]$ ``` It's fine for newlines to appear in method parameters as well as blocks, so Prism considers the EOF token to be the "error token". Indeed EOF "occurs" on line 2 (since it's after the newline), but since nobody writes EOF in to their files, I think we should consider the error to have occurred at the newline preceding EOF. One more example: ``` [aaron@tc-lan-adapter ~/g/ruby (master)]$ cat x.rb foo( [aaron@tc-lan-adapter ~/g/ruby (master)]$ wc -l x.rb 5 x.rb [aaron@tc-lan-adapter ~/g/ruby (master)]$ od -c x.rb 0000000 f o o ( \n \n \n \n \n 0000011 [aaron@tc-lan-adapter ~/g/ruby (master)]$ ./miniruby x.rb x.rb: x.rb:6: syntax error found (SyntaxError) 4 | 5 | > 6 | | ^ unexpected end-of-input; expected a `)` to close the arguments [aaron@tc-lan-adapter ~/g/ruby (master)]$ ``` Most tools agree the above file only has 5 lines in it, but Prism reports the error on line 6. IMO errors should only occur on lines that exist. ---------------------------------------- Bug #20918: Prism error indicates line number of `-e` that does not exist https://bugs.ruby-lang.org/issues/20918#change-110851 * Author: mame (Yusuke Endoh) * Status: Assigned * Assignee: prism * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- ``` $ ruby -e 'foo(' -e: -e:2: syntax error found (SyntaxError) 1 | foo( > 2 | | ^ unexpected end-of-input; expected a `)` to close the arguments ``` It says `-e:2`, but there is no line 2 in `-e 'foo('`. `eval("foo(")` reports line 1, so I guess this issue is only for `-e`. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/