This closes #56 issue on Github.
var = (njs_variable_t *) parser->target;
+ if (var->self) {
+ var->init = 1;
+ var->type = NJS_VARIABLE_CONST;
+ }
+
var->index = njs_scope_index(var->scope->type, var->scope->items,
- NJS_LEVEL_LOCAL, NJS_VARIABLE_VAR);
+ NJS_LEVEL_LOCAL, var->type);
var->scope->items++;
if (var->self) {
{ njs_str("var func = function x(x) {return x}; func()"),
njs_str("undefined") },
+ { njs_str("var func = function f() {f = null; return f;}; func()"),
+ njs_str("TypeError: assignment to constant variable") },
+
+ { njs_str("var func = function f() {let f = null; return f;}; func()"),
+ njs_str("null") },
+
#if 0 /* TODO */
{ njs_str("var a; Object.getOwnPropertyDescriptor(this, 'a').value"),
njs_str("undefined") },