jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • groovy
  • GROOVY-534

Nested closures - variable scope problem

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0-beta-5
  • Fix Version/s: 1.0-JSR-5
  • Component/s: None
  • Labels:
    None

Description

output = "a"
[1,1,1].each {
output = output + "b"
[1,1,1].each { output = output + "c" }
}
print output

I expected "abcccbcccbccc" but I get "abbb"

Issue Links

is depended upon by

Task - A task that needs to be done. GROOVY-754 scoping

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Task - A task that needs to be done. GROOVY-764 closures

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.
is duplicated by

Bug - A problem which impairs or prevents the functions of the product. GROOVY-918 Cannot set outside variables from within nested closures

  • Major - Major loss of function.
  • Closed - The issue is considered finished, the resolution is correct. Issues which are not closed can be reopened.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Chris Poirier added a comment - 21/Jun/04 9:31 PM

I haven't checked, but this looks like one of the variable scoping issues (the class gen code often mistakes the use of a variable for it's declaration). I've started writing a semantic analyzer that will fix this and a variety of other variable scoping issues, but I'm absolutely swamped right now with paying work, so it may be a while. Sorry.

Show
Chris Poirier added a comment - 21/Jun/04 9:31 PM I haven't checked, but this looks like one of the variable scoping issues (the class gen code often mistakes the use of a variable for it's declaration). I've started writing a semantic analyzer that will fix this and a variety of other variable scoping issues, but I'm absolutely swamped right now with paying work, so it may be a while. Sorry.
Hide
Permalink
blackdrag blackdrag added a comment - 19/Jan/06 6:50 PM

fixed now

Show
blackdrag blackdrag added a comment - 19/Jan/06 6:50 PM fixed now

People

  • Assignee:
    blackdrag blackdrag
    Reporter:
    Jonathan Aquino
Vote (0)
Watch (0)

Dates

  • Created:
    11/Jun/04 2:44 PM
    Updated:
    19/Jan/06 6:50 PM
    Resolved:
    19/Jan/06 6:50 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.