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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 8u60, 9
    • core-libs
    • None
    • b54
    • generic
    • generic

        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.

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

                Created:
                Updated:
                Resolved: