esprima-python icon indicating copy to clipboard operation
esprima-python copied to clipboard

Optional chaining

Open LivingInSyn opened this issue 3 years ago • 5 comments

Hi All,

This PR is a port of the following PR from the main esprima project:

https://github.com/jquery/esprima/pull/2048

I've hit a bit of a wall when running unit tests getting the added optional parameter to get serialized when toDict is called. Any help you can provide to fix that and get this merged would be great!

LivingInSyn avatar May 24 '21 17:05 LivingInSyn

An example is:

test/fixtures/declaration/function/migrated_0006.js

The expected output has this in the output: https://github.com/Kronuz/esprima-python/blob/2e108bf41d66a4c4517405d5d398225b250207f8/test/fixtures/declaration/function/migrated_0006.tree.json#L70

Where the actual just doesn't have optional as a member of the CallExpression object:

"expression": {
              "arguments": [],
              "callee": {
                "loc": {
                  "end": {
                    "column": 25,
                    "line": 1
                  },
                  "start": {
                    "column": 20,
                    "line": 1
                  }
                },
                "name": "sayHi",
                "range": [
                  20,
                  25
                ],
                "type": "Identifier"
              },
              "loc": {
                "end": {
                  "column": 27,
                  "line": 1
                },
                "start": {
                  "column": 20,
                  "line": 1
                }
              },
              "optional": false,
              "range": [
                20,
                27
              ],
              "type": "CallExpression"
            }
            

LivingInSyn avatar May 24 '21 17:05 LivingInSyn

Update: I was using the pip installed version while running tests

Removed unsupported tests. I plan on pulling in the following PRs in the near future:

https://github.com/jquery/esprima/pull/1190 https://github.com/jquery/esprima/issues/2032 https://github.com/jquery/esprima/issues/2039

Only two problems left to fix

LivingInSyn avatar May 24 '21 21:05 LivingInSyn

@Kronuz : spent a bit more time but I'm not sure how to where the last errors are coming from. On test/fixtures/expression/primary/literal/regular-expression/u-flag-surrogate-pair.js I get

"init": {
            "loc": {
              "end": {
                "column": 41, 
                "line": 1
              }, 
              "start": {
                "column": 8, 
                "line": 1
              }
            }, 
            "range": [
              8, 
              41
            ], 
            "raw": "/[\\uD834\\uDF06-\\uD834\\uDF08a-z]/u", 
            "regex": {
              "flags": "u", 
              "pattern": "[\\uD834\\uDF06-\\uD834\\uDF08a-z]"
            }, 
            "type": "Literal", 
            "value": {}
          }

I'm not sure where "value": {} is coming from given the changes made for this feature.

Any help you can provide would be appreciated

LivingInSyn avatar May 25 '21 00:05 LivingInSyn

Any idea when this is going to be done and merged?

djn3m0 avatar Feb 16 '22 17:02 djn3m0

@djn3m0 I dropped this work since I changed positions, sorry. IIRC we changed from esprima-python to using https://github.com/eslint/espree directly

LivingInSyn avatar Feb 17 '22 14:02 LivingInSyn