[
https://issues.apache.org/jira/browse/GROOVY-8472?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444077#comment-16444077
]
Paul King commented on GROOVY-8472:
-----------------------------------
I split the while loop into it's own issue
> Final variable analysis doesn't account for early exit for try/catch/finally
> ----------------------------------------------------------------------------
>
> Key: GROOVY-8472
> URL: https://issues.apache.org/jira/browse/GROOVY-8472
> Project: Groovy
> Issue Type: Improvement
> Reporter: Paul King
> Priority: Major
>
> 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}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)