Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4404

Variable scope of BlockStatement getting lost inside ReturnAdder

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.4, 1.8-beta-1
    • 1.7.5, 1.8-beta-2
    • class generator
    • None

    Description

      Inside of of ReturnAdder, there is the code:

      BlockStatement newBlock = new BlockStatement();
      newBlock.setVariableScope(node.getVariableScope());
      

      This is meant to ensure that the variable scope of the new block statement has the appropriate variable scope. However, node is of type MethodNode. The code block should be as follows:

      BlockStatement newBlock = new BlockStatement();
      Statement code = node.getCode();
      if (code instanceof BlockStatement) {
        newBlock.setVariableScope(((BlockStatement) code).getVariableScope());
      }
      

      If code is not of type BlockStatement, then we don't need to set the variable scope.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            werdna Andrew Eisenberg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: