[ 
https://issues.apache.org/jira/browse/GROOVY-8720?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149142#comment-18149142
 ] 

Daniel Sun commented on GROOVY-8720:
------------------------------------

Fixed on master; added a regression test in 
c3c68c899b4d184331f61f683b78a6405187e8a5 
(https://github.com/apache/groovy/commit/c3c68c899b4d184331f61f683b78a6405187e8a5).

> final variable set in try fails to compile if throws in catch
> -------------------------------------------------------------
>
>                 Key: GROOVY-8720
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8720
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.5.1
>            Reporter: Jex Jexler
>            Assignee: Daniel Sun
>            Priority: Minor
>             Fix For: 7.0.0-alpha-1
>
>
> {code:java}
> final Date date = new Date()
> final Long ms
> try {
>   ms = date.parse('')
> } catch (IllegalArgumentException e) {
>   throw new RuntimeException(e)
> }
> println ms
> {code}
> Expected result (Groovy 2.4.15):
> {noformat}
> Java.lang.RuntimeException: java.lang.IllegalArgumentException
>       at ConsoleScript0.run(ConsoleScript0:6)
> Caused by: java.lang.IllegalArgumentException
>       at java_util_Date$parse.call(Unknown Source)
>       at ConsoleScript0.run(ConsoleScript0:4)
> {noformat}
> Fails to compile with Groovy 2.5.1:
> {noformat}
> The variable [ms] may be uninitialized
> . At [8:9]  at line: 8, column: 9
> {noformat}



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to