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

const re-assignment should not reported as a "early error"

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u60, 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b54
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        const x = 1;
        print("hello world");
        x = 3;


        Should the output "hello world" be seen or not? Right now, nashorn treats this as "early error".

        But, see this:

        https://github.com/rwaldron/tc39-notes/blob/master/es6/2014-11/nov-18.md#43-assignment-to-a-const-static-error

        http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts

        Has these lines

        / Assigning to a const declared binding throw, even in non-strict mode code.
        Eliminated requirement to statically find and report assign to const declared names./

        under section "December 6, 2014 Draft Rev 29"

        So, it appears that the (as of now!) const re-assignment is reported as TypeError - but not an early error.

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  hannesw Hannes Wallnoefer
                  Reporter:
                  sundar Sundararajan Athijegannathan
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: