Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3F256200B9C for ; Mon, 10 Oct 2016 12:06:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3D8CC160AF6; Mon, 10 Oct 2016 10:06:22 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 7AF38160ACA for ; Mon, 10 Oct 2016 12:06:21 +0200 (CEST) Received: (qmail 48259 invoked by uid 500); 10 Oct 2016 10:06:20 -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 48236 invoked by uid 99); 10 Oct 2016 10:06:20 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Oct 2016 10:06:20 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 82CF82C0086 for ; Mon, 10 Oct 2016 10:06:20 +0000 (UTC) Date: Mon, 10 Oct 2016 10:06:20 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: notifications@groovy.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GROOVY-7291) Declaration of double variable without value assignment referrenced in closure MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 10 Oct 2016 10:06:22 -0000 [ https://issues.apache.org/jira/browse/GROOVY-7291?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15561865#comment-15561865 ] ASF GitHub Bot commented on GROOVY-7291: ---------------------------------------- GitHub user blindpirate opened a pull request: https://github.com/apache/groovy/pull/446 GROOVY-7291 Declaration of double variable without value assignment referrenced in closure According to [GROOVY-5570](https://issues.apache.org/jira/browse/GROOVY-5570), a variable referenced by closure must be non-primitive type, and it results in [GROOVY-7291](https://issues.apache.org/jira/browse/GROOVY-7291). In this case, I replace the EmptyExpression to a ConstantExpression with value 0. You can merge this pull request into a Git repository by running: $ git pull https://github.com/blindpirate/groovy groovy7291 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/446.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #446 ---- commit f8cb9b233ec1cfa4594f4d544ab12f9311cd4165 Author: zhangbo Date: 2016-10-10T09:53:36Z fix groovy 7291 bug ---- > Declaration of double variable without value assignment referrenced in closure > ------------------------------------------------------------------------------ > > Key: GROOVY-7291 > URL: https://issues.apache.org/jira/browse/GROOVY-7291 > Project: Groovy > Issue Type: Bug > Affects Versions: 1.8.6, 2.2.1, 2.4.0 > Environment: Windows 8.1, JDK 1.7_71 and 1.8_25 > Reporter: David Richter > Priority: Critical > Attachments: groovyBug.zip > > > I have problem with following code: > {code} > double a; > def b = { > a = a + 1; > } > b(); > {code} > I tried to compile it with groovy 1.8.6 and it worked > variable 'a' was instantiated with value 0.0 > but after upgrade to groovy 2.2.1 > it throws NullPointerException because variable 'a' is instantiated to null > I tried to decompile class files and declaration of 'a' looked like this: > version 1.8.6 > {noformat} > CallSite[] var1 = $getCallSiteArray(); > final Reference a = new Reference((Double)DefaultTypeTransformation.box(0.0D)); > DefaultTypeTransformation.doubleUnbox(a.get()); > ... > {noformat} > version 2.2.1 > {noformat} > CallSite[] var1 = $getCallSiteArray(); > final Reference a = new Reference((Object)null); > Double var10000 = (Double)a.get(); > ... > {noformat} > I tried it also with version 2.4.0 but it has same result as 2.2.1 > In attachment are groovy classes, compiled classes and consoleOutputs for versions 1.8.6 and 2.2.1 -- This message was sent by Atlassian JIRA (v6.3.4#6332)