Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
An example with early return from a method:
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)
And a slight rearrangement of above:
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)
Attachments
Issue Links
- is cloned by
-
GROOVY-8552 Final variable analysis doesn't account for early exit for while loop
- Open