Commit c8ecef5
committed
Reject unary-prefix left operand of '**' (TS17006)
`-x ** y` / `typeof x ** y` are syntax errors in JS/TS: the left operand of
`**` must be an UpdateExpression, not a UnaryExpression (write `(-x) ** y` or
`-(x ** y)`). We parsed it silently as `(-x) ** y`.
New declarable, language-agnostic operator property: `noUnaryLhs('**')` marks an
infix op whose left operand may not be a bare unary-prefix expression. The engine
enforces it generically — when such an op is about to bind and the lhs is a
prefix-op node whose operator is NOT also a postfix (i.e. a pure unary like
`-`/`!`/`typeof`, as opposed to an update `++`/`--`), the whole expression fails
hard (returns null). Failing hard (not just declining to bind) is required so it
can't reparse another way: left-assoc `(x ** -y) ** z`, or `typeof` degrading to a
bare identifier that splits the statement. The check sits at the LED, so
`(-x) ** y` is fine (lhs is a paren node, not a prefix node). It's a general
property — Python allows `-x ** y` and simply wouldn't declare it.
Correct across the boundary: rejects `-x ** y`, `typeof/void/delete/await x ** y`,
`x ** -y ** z`, `1 ** -2 ** 3`; still parses `x ** -y`, `(-x) ** y`, `-(x ** y)`,
`++x ** y`, `x++ ** y`, `2 ** 3 ** 4`, `-x * y`, `a = -b`.
FP 93->88 (5 es7/exponentiationOperator cases), FN stays 0 (3376/3376), TP
unchanged. agnostic 5/5, refactor-guard 112/112, highlighter 99.3% unchanged,
smoke pass. Artifacts regenerated.1 parent e632ff8 commit c8ecef5
4 files changed
Lines changed: 42 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
512 | | - | |
| 512 | + | |
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| |||
192 | 200 | | |
193 | 201 | | |
194 | 202 | | |
195 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
196 | 206 | | |
197 | 207 | | |
198 | 208 | | |
199 | 209 | | |
200 | 210 | | |
201 | 211 | | |
202 | | - | |
| 212 | + | |
203 | 213 | | |
| 214 | + | |
| 215 | + | |
204 | 216 | | |
205 | 217 | | |
206 | 218 | | |
207 | 219 | | |
208 | 220 | | |
209 | | - | |
| 221 | + | |
210 | 222 | | |
211 | 223 | | |
212 | 224 | | |
213 | | - | |
| 225 | + | |
214 | 226 | | |
215 | 227 | | |
216 | 228 | | |
217 | | - | |
| 229 | + | |
218 | 230 | | |
219 | 231 | | |
220 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
55 | 61 | | |
56 | 62 | | |
57 | 63 | | |
| 64 | + | |
58 | 65 | | |
59 | 66 | | |
60 | 67 | | |
| |||
65 | 72 | | |
66 | 73 | | |
67 | 74 | | |
| 75 | + | |
68 | 76 | | |
69 | 77 | | |
70 | 78 | | |
| |||
706 | 714 | | |
707 | 715 | | |
708 | 716 | | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
709 | 731 | | |
710 | 732 | | |
711 | 733 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
0 commit comments