Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8005843

refSymbol lookup of catch variable causes NullPointerException in Lower

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P3
    • 8
    • 8
    • core-libs
    • None

    Description

      {code}
      try {
          throw new TypeError('error');
      } catch (iox) {
          function f() {
      print(iox.message);
          }
      }
      {code}

      breaks

      Should throw reference error, according to Chapter 13 of the spec - function with out assignment to identifier is bound to lexical closure, not variable closure. One line fix is:

      change

      {code}
      final List<Block> lookupBlocks = findLookupBlocksHelper(getCurrentFunctionNode(), symbol.findFunction());
      for (final Block lookupBlock : lookupBlocks) {
           final Symbol refSymbol = lookupBlock.findSymbol(name);
           refSymbol.setIsScope();
      }
      {code}

      {code}
      final List<Block> lookupBlocks = findLookupBlocksHelper(getCurrentFunctionNode(), symbol.findFunction());
      for (final Block lookupBlock : lookupBlocks) {
            final Symbol refSymbol = lookupBlock.findSymbol(name);
            if (refSymbol != null) { // See NASHORN-837, function declaration in lexical scope: try {} catch (x){ function f() { use(x) } } f()
                  refSymbol.setIsScope();
             }
      }
      {code}

      Attachments

        Activity

          People

            lagergren Marcus Lagergren
            lagergren Marcus Lagergren
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: