Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

noop start and end loc is swapped #1063

Open
abdul-alhasany opened this issue Jan 31, 2023 · 0 comments
Open

noop start and end loc is swapped #1063

abdul-alhasany opened this issue Jan 31, 2023 · 0 comments

Comments

@abdul-alhasany
Copy link

Hi
When a body has noob child the start and end location are swapped. For example this code:

<?php
function test()
{
        /* taken from http://de3.php.net/manual/en/reserved.php */
    # $m[] = 'declare';
   /* taken from http://de3.php.net/manual/en/reserved.php */
   # $m[] = 'declare';
}

Produce this AST:

body {
   loc: {
      source: null
      start: {
         line: 3 <-- Correct value, but child have wrong value
         column: 0
         offset: 22
      }
      end: {
         line: 8 <-- Correct value, but child have wrong value
         column: 1
         offset: 201
      }
   }
   children: [
      noop  {
         leadingComments: [4 elements]
         loc: {
            start: {
               line: 8 <-- Start line should 3
               column: 0
               offset: 200
            }
            end: {
               line: 3 <-- End line should 8
               column: 1
               offset: 23
            }
         }
      }
   ]
}

As you can see the body loc is correct, but the child noop has the wrong start and end data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant