User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:18.104.22.168) Gecko/20060926 Ubuntu/breezy-security Firefox/22.214.171.124 Build Identifier: Rhino 1.6R5 Another JS 1.5 feature that RHino needs. Reproducible: Always Steps to Reproduce: 1. Start Rhino shell 2. enter 'const foo = 5;' 3. Actual Results: Parse error. Expected Results: Should work and protect foo from assignment.
I'm working on a fix for this.
Created attachment 255242 [details] [diff] [review] This is a PARTIAL patch to this bug. I will lay odds that this patch will crash if opt level is > -1. Do not integrate this patch. I just want comments on the semantics and the changes in interfaces.
FYI, bug 229756 reports the lack of write-once semantics in SpiderMonkey's const. /be
Created attachment 256211 [details] [diff] [review] This is a full patch This completes the implementation of const. There are a couple of validation tests that were failing always before (because they used const in them). These tests (js1_5/String/regress-354541-02.js and js1_5/String/regress-354541-04.js) now fail only on -opt -1 but pass on opt >= 0. Modifying the source to use 'var' instead of const exhibits the same behavior even without my changes. I therefore conclude that these failures are unrelated to my changes.
Bob, please see comment 4. /be
The referenced tests are now in js1_5/extensions/ due to the use of Script. Does Rhino even support Script? Brendan, I can change the use of const in the tests to var if that would fix the problem.
Changing const to var does not change the test outcome (I tried that to isolate the cause). Rhino does support Script, but these tests only work correctly on the compiled-thru-Java cde path. The stand-alone interpreter gets theanswer wrong. I traced the interpreted code path thru to the Script constructor and it appeared that it used the global scope as it's scope, and not the local scope of the caller (which is what the tests assume).
Created attachment 259915 [details] [diff] [review] Updated const patch that fixes problems with const in functions. This patch fixes the previously noted bug in the original patches.
Adding target milestone of 1.6R6 based on the date this bug was resolved FIXED.