diff --git a/.gitignore b/.gitignore index 2179108..16d4fb1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ dist composer.json composer.lock vendor +venv/ +.idea \ No newline at end of file diff --git a/code2flow/javascript.py b/code2flow/javascript.py index 711819b..23f9a0f 100644 --- a/code2flow/javascript.py +++ b/code2flow/javascript.py @@ -131,6 +131,8 @@ def process_assign(element): return [] if target['init']['type'] == 'NewExpression': + if 'name' not in target['id']: + return [] token = target['id']['name'] call = get_call_from_func_element(target['init']) if call: diff --git a/tests/test_code/js/destructor_new/destructor_new.js b/tests/test_code/js/destructor_new/destructor_new.js new file mode 100644 index 0000000..76bd3a8 --- /dev/null +++ b/tests/test_code/js/destructor_new/destructor_new.js @@ -0,0 +1,7 @@ +class A { + b() {}; +} + +const { b } = new A(); + +b(); diff --git a/tests/testdata.py b/tests/testdata.py index f3241a4..57cf49f 100644 --- a/tests/testdata.py +++ b/tests/testdata.py @@ -1582,6 +1582,12 @@ "moment::toInt", "moment::subtract$1", "moment::humanize"] + }, + { + "test_name": "destructor_new", + "directory": "destructor_new", + "expected_edges": [], + "expected_nodes": [] } ], 'mjs': [