interactive njs 0.2.7
v.<Tab> -> the properties and prototype methods of v.
type console.help() for more information
>> function a() { return 1; }
undefined
>> a()
1
>> function a() { return 2; }
undefined
>> a()
1
>>
@xeioex
Issues related to parser can be assigned to me.
@xeioex @drsm
Here's the patch.
https://gist.github.com/hongzhidao/71c795c834cc89413c4948d99a406ed7
BTW: style
diff -r 7345fd14d1b4 njs/njs_variable.c
--- a/njs/njs_variable.c Tue Feb 26 17:30:02 2019 +0800
+++ b/njs/njs_variable.c Wed Feb 27 10:59:19 2019 +0800
@@ -175,7 +175,7 @@ njs_reference_hash_test(nxt_lvlhsh_query
}
-const nxt_lvlhsh_proto_t njs_reference_hash_proto
+const nxt_lvlhsh_proto_t njs_references_hash_proto
nxt_aligned(64) =
{
NXT_LVLHSH_DEFAULT,
@@ -205,7 +205,7 @@ njs_variable_reference(njs_vm_t *vm, njs
lhq.key_hash = hash;
lhq.key = vr->name;
- lhq.proto = &njs_reference_hash_proto;
+ lhq.proto = &njs_references_hash_proto;
lhq.replace = 0;
lhq.value = node;
lhq.pool = vm->mem_pool;
@hongzhidao the patch works fine, thanks!
here is the test:
diff --git a/njs/test/njs_expect_test.exp b/njs/test/njs_expect_test.exp
--- a/njs/test/njs_expect_test.exp
+++ b/njs/test/njs_expect_test.exp
@@ -613,3 +613,15 @@
{"var crypto = require('crypto')\r\n"
"undefined\r\n"}
} "-s"
+
+# function declarations in interactive mode
+njs_test {
+ {"function a() { return 1; }\r\n"
+ "undefined\r\n>> "}
+ {"a();\r\n"
+ "1\r\n>> "}
+ {"function a() { return 2; }\r\n"
+ "undefined\r\n>> "}
+ {"a();\r\n"
+ "2\r\n>> "}
+}
@xeioex @drsm See again.
Style and Fixed patch.
https://gist.github.com/hongzhidao/71c795c834cc89413c4948d99a406ed7
Most helpful comment
@xeioex @drsm
Here's the patch.
https://gist.github.com/hongzhidao/71c795c834cc89413c4948d99a406ed7
BTW: style