Skip to content

Commit fa4ce46

Browse files
committed
Python: Fix locations of match unary operations
Somehow, in the original implementation of support for `match`, we had used `_start_location` instead of `_location_start`, which meant we didn't override the location after all. This was the only occurrence of this mistake in `python.tsg`.
1 parent cfb0925 commit fa4ce46

3 files changed

Lines changed: 32 additions & 32 deletions

File tree

‎python/extractor/tests/parser/match_new.expected‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Module: [1, 0] - [61, 0]
8585
literal:
8686
BinOp: [8, 9] - [8, 18]
8787
left:
88-
UnaryOp: [8, 10] - [8, 11]
88+
UnaryOp: [8, 9] - [8, 11]
8989
op: USub
9090
operand:
9191
Num: [8, 10] - [8, 11]
@@ -104,7 +104,7 @@ Module: [1, 0] - [61, 0]
104104
pattern:
105105
MatchLiteralPattern: [10, 9] - [10, 11]
106106
literal:
107-
UnaryOp: [10, 10] - [10, 11]
107+
UnaryOp: [10, 9] - [10, 11]
108108
op: USub
109109
operand:
110110
Num: [10, 10] - [10, 11]
@@ -131,7 +131,7 @@ Module: [1, 0] - [61, 0]
131131
literal:
132132
BinOp: [14, 9] - [14, 16]
133133
left:
134-
UnaryOp: [14, 10] - [14, 13]
134+
UnaryOp: [14, 9] - [14, 13]
135135
op: USub
136136
operand:
137137
Num: [14, 10] - [14, 13]
@@ -389,7 +389,7 @@ Module: [1, 0] - [61, 0]
389389
pattern:
390390
MatchLiteralPattern: [45, 9] - [45, 11]
391391
literal:
392-
UnaryOp: [45, 10] - [45, 11]
392+
UnaryOp: [45, 9] - [45, 11]
393393
op: UAdd
394394
operand:
395395
Num: [45, 10] - [45, 11]
@@ -403,7 +403,7 @@ Module: [1, 0] - [61, 0]
403403
pattern:
404404
MatchLiteralPattern: [47, 9] - [47, 13]
405405
literal:
406-
UnaryOp: [47, 10] - [47, 13]
406+
UnaryOp: [47, 9] - [47, 13]
407407
op: UAdd
408408
operand:
409409
Num: [47, 10] - [47, 13]
@@ -417,7 +417,7 @@ Module: [1, 0] - [61, 0]
417417
pattern:
418418
MatchLiteralPattern: [49, 9] - [49, 12]
419419
literal:
420-
UnaryOp: [49, 10] - [49, 12]
420+
UnaryOp: [49, 9] - [49, 12]
421421
op: UAdd
422422
operand:
423423
Num: [49, 10] - [49, 12]
@@ -433,7 +433,7 @@ Module: [1, 0] - [61, 0]
433433
literal:
434434
BinOp: [51, 9] - [51, 14]
435435
left:
436-
UnaryOp: [51, 10] - [51, 11]
436+
UnaryOp: [51, 9] - [51, 11]
437437
op: UAdd
438438
operand:
439439
Num: [51, 10] - [51, 11]
@@ -454,7 +454,7 @@ Module: [1, 0] - [61, 0]
454454
literal:
455455
BinOp: [53, 9] - [53, 14]
456456
left:
457-
UnaryOp: [53, 10] - [53, 11]
457+
UnaryOp: [53, 9] - [53, 11]
458458
op: UAdd
459459
operand:
460460
Num: [53, 10] - [53, 11]
@@ -475,23 +475,23 @@ Module: [1, 0] - [61, 0]
475475
patterns: [
476476
MatchLiteralPattern: [55, 9] - [55, 14]
477477
literal:
478-
UnaryOp: [55, 10] - [55, 14]
478+
UnaryOp: [55, 9] - [55, 14]
479479
op: UAdd
480480
operand:
481481
Num: [55, 10] - [55, 14]
482482
n: 16
483483
text: '0x10'
484484
MatchLiteralPattern: [55, 17] - [55, 22]
485485
literal:
486-
UnaryOp: [55, 18] - [55, 22]
486+
UnaryOp: [55, 17] - [55, 22]
487487
op: UAdd
488488
operand:
489489
Num: [55, 18] - [55, 22]
490490
n: 8
491491
text: '0o10'
492492
MatchLiteralPattern: [55, 25] - [55, 30]
493493
literal:
494-
UnaryOp: [55, 26] - [55, 30]
494+
UnaryOp: [55, 25] - [55, 30]
495495
op: UAdd
496496
operand:
497497
Num: [55, 26] - [55, 30]
@@ -508,15 +508,15 @@ Module: [1, 0] - [61, 0]
508508
patterns: [
509509
MatchLiteralPattern: [57, 10] - [57, 12]
510510
literal:
511-
UnaryOp: [57, 11] - [57, 12]
511+
UnaryOp: [57, 10] - [57, 12]
512512
op: UAdd
513513
operand:
514514
Num: [57, 11] - [57, 12]
515515
n: 0
516516
text: '0'
517517
MatchLiteralPattern: [57, 14] - [57, 18]
518518
literal:
519-
UnaryOp: [57, 15] - [57, 18]
519+
UnaryOp: [57, 14] - [57, 18]
520520
op: USub
521521
operand:
522522
Num: [57, 15] - [57, 18]
@@ -535,7 +535,7 @@ Module: [1, 0] - [61, 0]
535535
key:
536536
MatchLiteralPattern: [59, 10] - [59, 12]
537537
literal:
538-
UnaryOp: [59, 11] - [59, 12]
538+
UnaryOp: [59, 10] - [59, 12]
539539
op: UAdd
540540
operand:
541541
Num: [59, 11] - [59, 12]
@@ -551,7 +551,7 @@ Module: [1, 0] - [61, 0]
551551
key:
552552
MatchLiteralPattern: [59, 17] - [59, 21]
553553
literal:
554-
UnaryOp: [59, 18] - [59, 21]
554+
UnaryOp: [59, 17] - [59, 21]
555555
op: UAdd
556556
operand:
557557
Num: [59, 18] - [59, 21]
@@ -567,7 +567,7 @@ Module: [1, 0] - [61, 0]
567567
key:
568568
MatchLiteralPattern: [59, 26] - [59, 29]
569569
literal:
570-
UnaryOp: [59, 27] - [59, 29]
570+
UnaryOp: [59, 26] - [59, 29]
571571
op: UAdd
572572
operand:
573573
Num: [59, 27] - [59, 29]

‎python/extractor/tsg-python/python.tsg‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2825,7 +2825,7 @@
28252825
var left_node = #null
28262826
if some @prefix_op {
28272827
set left_node = (ast-node @left "UnaryOp")
2828-
attr (left_node) _start_location = (location-start @prefix_op)
2828+
attr (left_node) _location_start = (location-start @prefix_op)
28292829
attr (left_node) operand = @left.node
28302830
if (eq (source-text @prefix_op) "+") {
28312831
attr (left_node) op = "uadd"
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
| test.py:2:11:2:11 | UnaryExpr | UAdd |
2-
| test.py:4:11:4:13 | UnaryExpr | UAdd |
3-
| test.py:6:11:6:12 | UnaryExpr | UAdd |
4-
| test.py:8:11:8:11 | UnaryExpr | UAdd |
5-
| test.py:10:11:10:11 | UnaryExpr | UAdd |
6-
| test.py:12:11:12:14 | UnaryExpr | UAdd |
7-
| test.py:12:19:12:22 | UnaryExpr | UAdd |
8-
| test.py:12:27:12:30 | UnaryExpr | UAdd |
9-
| test.py:14:12:14:12 | UnaryExpr | UAdd |
10-
| test.py:14:16:14:18 | UnaryExpr | USub |
11-
| test.py:16:12:16:12 | UnaryExpr | UAdd |
12-
| test.py:16:19:16:21 | UnaryExpr | UAdd |
13-
| test.py:16:28:16:29 | UnaryExpr | UAdd |
14-
| test.py:18:11:18:11 | UnaryExpr | USub |
15-
| test.py:20:11:20:11 | UnaryExpr | USub |
1+
| test.py:2:10:2:11 | UnaryExpr | UAdd |
2+
| test.py:4:10:4:13 | UnaryExpr | UAdd |
3+
| test.py:6:10:6:12 | UnaryExpr | UAdd |
4+
| test.py:8:10:8:11 | UnaryExpr | UAdd |
5+
| test.py:10:10:10:11 | UnaryExpr | UAdd |
6+
| test.py:12:10:12:14 | UnaryExpr | UAdd |
7+
| test.py:12:18:12:22 | UnaryExpr | UAdd |
8+
| test.py:12:26:12:30 | UnaryExpr | UAdd |
9+
| test.py:14:11:14:12 | UnaryExpr | UAdd |
10+
| test.py:14:15:14:18 | UnaryExpr | USub |
11+
| test.py:16:11:16:12 | UnaryExpr | UAdd |
12+
| test.py:16:18:16:21 | UnaryExpr | UAdd |
13+
| test.py:16:27:16:29 | UnaryExpr | UAdd |
14+
| test.py:18:10:18:11 | UnaryExpr | USub |
15+
| test.py:20:10:20:11 | UnaryExpr | USub |

0 commit comments

Comments
 (0)