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

PHP dowhile body/condition loops are reversed #650

Open
bdrodes opened this issue Jun 8, 2021 · 1 comment
Open

PHP dowhile body/condition loops are reversed #650

bdrodes opened this issue Jun 8, 2021 · 1 comment

Comments

@bdrodes
Copy link

bdrodes commented Jun 8, 2021

I'm using the 'latest' docker tag. PHP dowhile loops have the body/condition inverted (the condition is listed in the body and the body in the condition).

<?php
    $i = 0;
    $sum = 0;
    do{
        $sum = $sum + 1;
        $i = $i + 1;
    }while($i < 3);

Results in the following --json output (note doWhileBody and doWhileCondition.

I'm currently using 'latest' since the current docker listed here https://github.com/github/semantic/packages/11609 does not support --json anymore.

[{'term': 'Empty',
  'sourceRange': [10, 10],
  'sourceSpan': {'start': [2, 5], 'end': [2, 5]}},
 {'term': 'Assignment',
  'assignmentContext': [],
  'assignmentTarget': {'term': 'VariableName',
   'value': {'term': 'Identifier',
    'name': 'i',
    'sourceRange': [11, 12],
    'sourceSpan': {'start': [2, 6], 'end': [2, 7]}},
   'sourceRange': [10, 12],
   'sourceSpan': {'start': [2, 5], 'end': [2, 7]}},
  'assignmentValue': {'term': 'Integer',
   'integerContent': '0',
   'sourceRange': [15, 16],
   'sourceSpan': {'start': [2, 10], 'end': [2, 11]}},
  'sourceRange': [10, 16],
  'sourceSpan': {'start': [2, 5], 'end': [2, 11]}},
 {'term': 'Assignment',
  'assignmentContext': [],
  'assignmentTarget': {'term': 'VariableName',
   'value': {'term': 'Identifier',
    'name': 'sum',
    'sourceRange': [23, 26],
    'sourceSpan': {'start': [3, 6], 'end': [3, 9]}},
   'sourceRange': [22, 26],
   'sourceSpan': {'start': [3, 5], 'end': [3, 9]}},
  'assignmentValue': {'term': 'Integer',
   'integerContent': '0',
   'sourceRange': [29, 30],
   'sourceSpan': {'start': [3, 12], 'end': [3, 13]}},
  'sourceRange': [22, 30],
  'sourceSpan': {'start': [3, 5], 'end': [3, 13]}},
 {'term': 'DoWhile',
  'doWhileBody': {'term': 'LessThan',
   'lhs': {'term': 'VariableName',
    'value': {'term': 'Identifier',
     'name': 'i',
     'sourceRange': [98, 99],
     'sourceSpan': {'start': [7, 13], 'end': [7, 14]}},
    'sourceRange': [97, 99],
    'sourceSpan': {'start': [7, 12], 'end': [7, 14]}},
   'rhs': {'term': 'Integer',
    'integerContent': '3',
    'sourceRange': [102, 103],
    'sourceSpan': {'start': [7, 17], 'end': [7, 18]}},
   'sourceRange': [97, 103],
   'sourceSpan': {'start': [7, 12], 'end': [7, 18]}},
  'doWhileCondition': {'children': [{'term': 'Assignment',
     'assignmentContext': [],
     'assignmentTarget': {'term': 'VariableName',
      'value': {'term': 'Identifier',
       'name': 'sum',
       'sourceRange': [49, 52],
       'sourceSpan': {'start': [5, 10], 'end': [5, 13]}},
      'sourceRange': [48, 52],
      'sourceSpan': {'start': [5, 9], 'end': [5, 13]}},
     'assignmentValue': {'term': 'Plus',
      'lhs': {'term': 'VariableName',
       'value': {'term': 'Identifier',
        'name': 'sum',
        'sourceRange': [56, 59],
        'sourceSpan': {'start': [5, 17], 'end': [5, 20]}},
       'sourceRange': [55, 59],
       'sourceSpan': {'start': [5, 16], 'end': [5, 20]}},
      'rhs': {'term': 'Integer',
       'integerContent': '1',
       'sourceRange': [62, 63],
       'sourceSpan': {'start': [5, 23], 'end': [5, 24]}},
      'sourceRange': [55, 63],
      'sourceSpan': {'start': [5, 16], 'end': [5, 24]}},
     'sourceRange': [48, 63],
     'sourceSpan': {'start': [5, 9], 'end': [5, 24]}},
    {'term': 'Assignment',
     'assignmentContext': [],
     'assignmentTarget': {'term': 'VariableName',
      'value': {'term': 'Identifier',
       'name': 'i',
       'sourceRange': [74, 75],
       'sourceSpan': {'start': [6, 10], 'end': [6, 11]}},
      'sourceRange': [73, 75],
      'sourceSpan': {'start': [6, 9], 'end': [6, 11]}},
     'assignmentValue': {'term': 'Plus',
      'lhs': {'term': 'VariableName',
       'value': {'term': 'Identifier',
        'name': 'i',
        'sourceRange': [79, 80],
        'sourceSpan': {'start': [6, 15], 'end': [6, 16]}},
       'sourceRange': [78, 80],
       'sourceSpan': {'start': [6, 14], 'end': [6, 16]}},
      'rhs': {'term': 'Integer',
       'integerContent': '1',
       'sourceRange': [83, 84],
       'sourceSpan': {'start': [6, 19], 'end': [6, 20]}},
      'sourceRange': [78, 84],
      'sourceSpan': {'start': [6, 14], 'end': [6, 20]}},
     'sourceRange': [73, 84],
     'sourceSpan': {'start': [6, 9], 'end': [6, 20]}}],
   'sourceRange': [38, 91],
   'sourceSpan': {'start': [4, 7], 'end': [7, 6]}},
  'sourceRange': [36, 105],
  'sourceSpan': {'start': [4, 5], 'end': [7, 20]}},
 {'term': 'Empty',
  'sourceRange': [105, 105],
  'sourceSpan': {'start': [7, 20], 'end': [7, 20]}}]
@patrickt patrickt changed the title dowhile Php PHP dowhile body/condition loops are reversed Aug 24, 2021
@patrickt
Copy link
Contributor

This may just need a tree-sitter bump.

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

2 participants