]> git.kaiwu.me - njs.git/commitdiff
Mark anonymous and unknown functions with <>.
authorDmitry Volyntsev <xeioex@nginx.com>
Fri, 30 Jan 2026 00:13:13 +0000 (16:13 -0800)
committerDmitry Volyntsev <xeioexception@gmail.com>
Thu, 5 Feb 2026 23:32:12 +0000 (15:32 -0800)
To separate from normal functions with the same name.

src/njs_vm.c
src/test/njs_benchmark.c
src/test/njs_unit_test.c

index 5220faeb91bf3fe5359f778699a48faa00144216..a9564241f643b48aff0613a991bd089a1bc24798 100644 (file)
@@ -14,8 +14,8 @@ static njs_int_t njs_vm_protos_init(njs_vm_t *vm, njs_value_t *global);
 const njs_str_t  njs_entry_empty =          njs_str("");
 const njs_str_t  njs_entry_main =           njs_str("main");
 const njs_str_t  njs_entry_module =         njs_str("module");
-const njs_str_t  njs_entry_unknown =        njs_str("unknown");
-const njs_str_t  njs_entry_anonymous =      njs_str("anonymous");
+const njs_str_t  njs_entry_unknown =        njs_str("<unknown>");
+const njs_str_t  njs_entry_anonymous =      njs_str("<anonymous>");
 
 
 void
index e83e239c10a84cb032004b06c37e6d44489d0773..cdb5954e30fd26dac03a033dec235453f3ffdecf 100644 (file)
@@ -477,13 +477,13 @@ static njs_benchmark_test_t  njs_test[] =
 
     { "exception.stack",
       njs_str("function f() { try { throw new Error('test') } catch (e) { return e.stack } } [f].map(v=>v())[0]"),
-      njs_str("Error: test\n    at f (:1)\n    at anonymous (:1)\n    at map (native)\n    at main (:1)\n"),
+      njs_str("Error: test\n    at f (:1)\n    at <anonymous> (:1)\n    at map (native)\n    at main (:1)\n"),
       100 },
 
     { "exception.native.stack",
       njs_str("function f() { try { 'str'.replace(/t/g,function(m) {return m.a.a}) } catch (e) { return e.stack } }; f()"),
       njs_str("TypeError: cannot get property \"a\" of undefined\n"
-              "    at anonymous (:1)\n"
+              "    at <anonymous> (:1)\n"
               "    at [Symbol.replace] (native)\n"
               "    at replace (native)\n"
               "    at f (:1)\n"
index 84a8709ac76fc16e9543889a7f5e9fc3d79a17c0..ddb92c047dbfd1e3605996c923957e91e1a2efdf 100644 (file)
@@ -21536,14 +21536,14 @@ static njs_unit_test_t  njs_backtraces_test[] =
     { njs_str("function f(ff, o) {return ff(o)};"
               "f(function (o) {return o.a.a}, {})"),
       njs_str("TypeError: cannot get property \"a\" of undefined\n"
-              "    at anonymous (:1)\n"
+              "    at <anonymous> (:1)\n"
               "    at f (:1)\n"
               "    at main (:1)\n") },
 
     { njs_str("'str'.replace(/t/g,"
               "              function(m) {return m.a.a})"),
       njs_str("TypeError: cannot get property \"a\" of undefined\n"
-              "    at anonymous (:1)\n"
+              "    at <anonymous> (:1)\n"
               "    at [Symbol.replace] (native)\n"
               "    at replace (native)\n"
               "    at main (:1)\n") },
@@ -21638,7 +21638,7 @@ static njs_unit_test_t  njs_backtraces_test[] =
               "               return ff(o)};"
               "f({})"),
       njs_str("TypeError: cannot get property \"a\" of undefined\n"
-              "    at anonymous (:1)\n"
+              "    at <anonymous> (:1)\n"
               "    at f (:1)\n"
               "    at main (:1)\n") },
 
@@ -21683,17 +21683,17 @@ static njs_unit_test_t  njs_backtraces_test[] =
 
     { njs_str("/**/(function(){throw Error();})()"),
       njs_str("Error\n"
-              "    at anonymous (:1)\n"
+              "    at <anonymous> (:1)\n"
               "    at main (:1)\n") },
 
     { njs_str("/***/(function(){throw Error();})()"),
       njs_str("Error\n"
-              "    at anonymous (:1)\n"
+              "    at <anonymous> (:1)\n"
               "    at main (:1)\n") },
 
     { njs_str("/*\n**/(function(){throw Error();})()"),
       njs_str("Error\n"
-              "    at anonymous (:2)\n"
+              "    at <anonymous> (:2)\n"
               "    at main (:2)\n") },
 
     { njs_str("({})\n.a\n.a"),