From notifications-return-11910-archive-asf-public=cust-asf.ponee.io@groovy.apache.org Thu Apr 19 15:56:05 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id C056818076D for ; Thu, 19 Apr 2018 15:56:04 +0200 (CEST) Received: (qmail 62668 invoked by uid 500); 19 Apr 2018 13:56:03 -0000 Mailing-List: contact notifications-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list notifications@groovy.apache.org Received: (qmail 62659 invoked by uid 99); 19 Apr 2018 13:56:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Apr 2018 13:56:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 754351A01BE for ; Thu, 19 Apr 2018 13:56:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -102.311 X-Spam-Level: X-Spam-Status: No, score=-102.311 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id ZMPxyfLofFyb for ; Thu, 19 Apr 2018 13:56:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 267B35F11F for ; Thu, 19 Apr 2018 13:56:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 34EA8E0CAE for ; Thu, 19 Apr 2018 13:56:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id A494C241CE for ; Thu, 19 Apr 2018 13:56:00 +0000 (UTC) Date: Thu, 19 Apr 2018 13:56:00 +0000 (UTC) From: "Paul King (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Created] (GROOVY-8552) Final variable analysis doesn't account for early exit for while loop MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Paul King created GROOVY-8552: --------------------------------- Summary: Final variable analysis doesn't account for early exit for while loop Key: GROOVY-8552 URL: https://issues.apache.org/jira/browse/GROOVY-8552 Project: Groovy Issue Type: Improvement Reporter: Paul King An example with early return from a method: {code} def method(String foo) { final str try { str = foo.trim() } catch(e) { println e return null } int exitCode = str.isInteger() ? str.toInteger() : null exitCode //str.isInteger() ? str.toInteger() : null // this doesn't trigger the error } println method(null) {code} And a slight rearrangement of above: {code} def method(String foo) { final str try { return foo.trim() } catch(e) { str = '-1' } int exitCode = str.toInteger() // The variable [str] may be uninitialized exitCode } println method(null) {code} Another example with a while loop: {code} int index final result = -1 int val = 2 while(true) { try { index = 12/val-- } catch(e) { break } println index // okay result = index // The variable [index] may be uninitialized } println result // should be found but isn't if -1 above is commented out {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)