pfp icon indicating copy to clipboard operation
pfp copied to clipboard

wrong _pfp__path() when traversing an array

Open michaelmera opened this issue 3 years ago • 0 comments

Describe the bug

Calling _pfp__path() on any DOM element contained in an array of non-primitive items returns the wrong result. The result is truncated at the array level and the name of the array items are sometime of the form None[i], even when the array has a name.

To Reproduce

    def test_path_for_array_items(self):
        dom = self._test_parse_build(
            "\x00\x00\x11\x11\x22\x22",
            """
                typedef struct _two_chars {
                    char x;
                    char y;
                } two_chars;

                struct {
                    two_chars the_array[3];
                } missing;
            """
        )

        self.assertEqual(dom.missing.the_array[1]._pfp__path(), "missing.the_array[1]")      # but get "None[1]"
        self.assertEqual(dom.missing.the_array[1].x._pfp__path(), "missing.the_array[1].x")  # but get "None[1].x"
        self.assertEqual(dom.missing.the_array[1].y._pfp__path(), "missing.the_array[1].y")  # but get "None[1].y"

Expected Behavior

The complete path should be retrieved, and it should include the correct name for the array.

michaelmera avatar Aug 11 '21 20:08 michaelmera