From: Dmitry Volyntsev Date: Tue, 26 Nov 2019 12:01:02 +0000 (+0300) Subject: Fixed "accumulative" mode of VM. X-Git-Tag: 0.3.8~51 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=ff6a04ab50b8cbfdaf56a2d12467e6e652b888c6;p=njs.git Fixed "accumulative" mode of VM. The issue was introduced in 452ce96df2e3. This closes #258 issue on Github. --- diff --git a/src/njs_vm.c b/src/njs_vm.c index 354a49da..19ec0e97 100644 --- a/src/njs_vm.c +++ b/src/njs_vm.c @@ -195,7 +195,7 @@ njs_vm_compile(njs_vm_t *vm, u_char **start, u_char *end) vm->variables_hash = scope->variables; - if (vm->options.init) { + if (vm->options.init && !vm->options.accumulative) { ret = njs_vm_init(vm); if (njs_slow_path(ret != NJS_OK)) { return ret; diff --git a/src/test/njs_interactive_test.c b/src/test/njs_interactive_test.c index 931b7997..fb384a02 100644 --- a/src/test/njs_interactive_test.c +++ b/src/test/njs_interactive_test.c @@ -75,6 +75,16 @@ static njs_interactive_test_t njs_test[] = { njs_str("/abc/i.test('ABC')" ENTER), njs_str("true") }, + /* Accumulative mode. */ + + { njs_str("var a = 1" ENTER + "a" ENTER), + njs_str("1") }, + + { njs_str("Number.prototype.test = 'test'" ENTER + "Number.prototype.test" ENTER), + njs_str("test") }, + /* Error handling */ { njs_str("var a = ;" ENTER