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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_PASS,T_SPF_HELO_TEMPERROR autolearn=ham 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) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id DC5081F44D for ; Fri, 26 Apr 2024 17:21:56 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (1024-bit key; secure) header.d=ml.ruby-lang.org header.i=@ml.ruby-lang.org header.a=rsa-sha256 header.s=mail header.b=n93g51jF; 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=Qsrvlbmd; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 2ABDF844E3; Fri, 26 Apr 2024 17:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ml.ruby-lang.org; s=mail; t=1714152108; bh=gQPnbZW2SgvyMLhWHYv+WQZEmnWDGLBJft8RgCe6DPs=; 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=n93g51jF5wIuVrS1p4J286xHHM9eGub4/EOsnsxC7VRFLyebmCmyKuYFwPHvCF5Y3 1Om0C69Z1Kl80LKH7vd2HTetg7Y11pLXK3/nFrCfJAKAeXxmZvZ2aJRKe6e8Bg16zq iyCVw6soMJ7fw5MQoqouRGNaC/0w8ur5HEi8dn40= Received: from s.wfbtzhsw.outbound-mail.sendgrid.net (s.wfbtzhsw.outbound-mail.sendgrid.net [159.183.224.105]) by nue.mailmanlists.eu (Postfix) with ESMTPS id BBCE18442C for ; Fri, 26 Apr 2024 17:21:44 +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=Qsrvlbmd; dkim-atps=neutral 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=nOJpwF8mZzwNNDzHMaqwfDBJkKO4vkZolpI3NNohFWU=; b=QsrvlbmdlmbS5t71dyNap6t1Jf59DU/p7OysvCOfKGp/wYH4RfgOVMLKhlR0opVKyiCc E2FroP6LID+0CoiAY7cgUm4Azlb955u+n2s3zc2j5+Euh9ojg1+Zf9CdQi41S70vqEJttz IKHV2wRTc0lskl142vuI5OdqhcCiDnamlBlY1KKF/hzYnNhPhqvP9TNHHY6/eTNypUNF8a V3WOQpJmEDkUYPp+5jHmNueIqBuLhFYH5s3JcNpRjhHjy/AYD3VFdfnfk+zkY/pPcUJr4K G9p7pXbvp39BLWjbER3o3aXnGCRUK1ACs66h513Jiy/AMjReNq/HyllFyHrKkv7Q== Received: by filterdrecv-5744f46764-6sgx2 with SMTP id filterdrecv-5744f46764-6sgx2-1-662BE2A7-16 2024-04-26 17:21:43.774496488 +0000 UTC m=+1193627.563180869 Received: from herokuapp.com (unknown) by geopod-ismtpd-4 (SG) with ESMTP id M8C9wLofT3e3qOCIOmehHw for ; Fri, 26 Apr 2024 17:21:43.716 +0000 (UTC) Date: Fri, 26 Apr 2024 17:21:43 +0000 (UTC) Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Bug X-Redmine-Issue-Id: 20457 X-Redmine-Issue-Author: tenderlovemaking X-Redmine-Issue-Priority: Normal X-Redmine-Sender: Eregon 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: 94325 X-SG-EID: =?us-ascii?Q?u001=2EByjZWvxTCjdoV8K03xEuhE7KqN4thWULFLM7+oH78KY30oYB3qFthsDpL?= =?us-ascii?Q?4w4cbYa3ttBh8bAHPOnE=2FkzPba67JNu7Lnrked2?= =?us-ascii?Q?O7K9VQ=2FJax0wEwrV9jC7Mvo2H3qm3clTy6q2lBk?= =?us-ascii?Q?+8LRNlCwZ6covyvd2A7x9vFiel8P2Vs9w9KG=2FxA?= =?us-ascii?Q?C7wL+uQtR4z97hkUIqB=2FEQKMOufUVJjW4vYSDLm?= =?us-ascii?Q?8QC9rqP7cMm5ZWdmS+ZGiBwF8rme+tAZMZ+49oD?= =?us-ascii?Q?noYAei4piknIlEtB8CP3yyrRtw=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: u001.I8uzylDtAfgbeCOeLBYDww== Message-ID-Hash: H6DV77Z573HNM3QHAUYL463MQR6GATT6 X-Message-ID-Hash: H6DV77Z573HNM3QHAUYL463MQR6GATT6 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.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:117729] [Ruby master Bug#20457] Final `return` is eliminated from the AST List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: "Eregon (Benoit Daloze) via ruby-core" Cc: "Eregon (Benoit Daloze)" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #20457 has been updated by Eregon (Benoit Daloze). I want to add for context that naturally Prism already provides this information (and much more) and has a much better API. Nobody should use `RubyVM::AbstractSyntaxTree`, as its documentation pretty much already says. ---------------------------------------- Bug #20457: Final `return` is eliminated from the AST https://bugs.ruby-lang.org/issues/20457#change-108136 * Author: tenderlovemaking (Aaron Patterson) * Status: Open * Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN ---------------------------------------- Given the following code: ```ruby def foo a = 1 return a end ``` If you parse this with RubyVM::AbstractSyntaxTree, the AST will be missing the `return` node. Of course the `return` node isn't necessary for compilation, but would be required for building an LSP for example. Here's a full program to demonstrate: ```ruby ast = RubyVM::AbstractSyntaxTree.parse DATA.read pp ast # Output is like this: # # (SCOPE@1:0-4:3 # tbl: [] # args: nil # body: # (DEFN@1:0-4:3 # mid: :foo # body: # (SCOPE@1:0-4:3 # tbl: [:a] # args: (ARGS@1:7-1:7 pre_num: 0 pre_init: nil opt: nil first_post: nil post_num: 0 post_init: nil rest: nil kw: nil kwrest: nil block: nil) # body: (BLOCK@2:2-3:10 (LASGN@2:2-2:7 :a (INTEGER@2:6-2:7 1)) (LVAR@3:9-3:10 :a))))) __END__ def foo a = 1 return a end ``` Btw, I'm happy to write failing tests for this type of stuff I'm just not sure where to put it! :) -- 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/postorius/lists/ruby-core.ml.ruby-lang.org/