Skip to content

Commit cd202a5

Browse files
committed
Do not treat use expression followed by ++ as cast expression
Fixes #526
1 parent d6ee336 commit cd202a5

File tree

4 files changed

+81
-2
lines changed

4 files changed

+81
-2
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ repository:
10891089
# If '<' is preceeded by 'return', 'throw', 'yield', or 'await', it's most likely a type assertion
10901090
# If '=', '(', ',', ':', or '>' are followed by a '<', it is also likely a type assertion as otherwise it would be a syntax error
10911091
# '<=' and '<<=' are cannot be type assertions, as they are assignment operators.
1092-
begin: (?:(?<=return|throw|yield|await|default|[=(,:>+*?]))\s*(<)(?!<?\=)
1092+
begin: (?:(?<=return|throw|yield|await|default|[=(,:>*?]|[^+]\+))\s*(<)(?!<?\=)
10931093
beginCaptures:
10941094
'1': { name: meta.brace.angle.ts }
10951095
end: (\>)\s*

TypeScript.tmLanguage

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3417,7 +3417,7 @@
34173417
<key>name</key>
34183418
<string>cast.expr.ts</string>
34193419
<key>begin</key>
3420-
<string>(?:(?&lt;=return|throw|yield|await|default|[=(,:&gt;+*?]))\s*(&lt;)(?!&lt;?\=)</string>
3420+
<string>(?:(?&lt;=return|throw|yield|await|default|[=(,:&gt;*?]|[^+]\+))\s*(&lt;)(?!&lt;?\=)</string>
34213421
<key>beginCaptures</key>
34223422
<dict>
34233423
<key>1</key>

tests/baselines/Issue526.baseline.txt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
original file
2+
-----------------------------------
3+
if (a++ < b) {
4+
}
5+
6+
export class A extends B {
7+
}
8+
-----------------------------------
9+
10+
Grammar: TypeScript.tmLanguage
11+
-----------------------------------
12+
>if (a++ < b) {
13+
^^
14+
source.ts keyword.control.conditional.ts
15+
^
16+
source.ts
17+
^
18+
source.ts meta.brace.round.ts
19+
^
20+
source.ts variable.other.readwrite.ts
21+
^^
22+
source.ts keyword.operator.increment.ts
23+
^
24+
source.ts
25+
^
26+
source.ts keyword.operator.relational.ts
27+
^
28+
source.ts
29+
^
30+
source.ts variable.other.readwrite.ts
31+
^
32+
source.ts meta.brace.round.ts
33+
^
34+
source.ts
35+
^
36+
source.ts meta.block.ts punctuation.definition.block.ts
37+
^^
38+
source.ts meta.block.ts
39+
>}
40+
^
41+
source.ts meta.block.ts punctuation.definition.block.ts
42+
^^
43+
source.ts
44+
>
45+
^^
46+
source.ts
47+
>export class A extends B {
48+
^^^^^^
49+
source.ts meta.class.ts keyword.control.export.ts
50+
^
51+
source.ts meta.class.ts
52+
^^^^^
53+
source.ts meta.class.ts storage.type.class.ts
54+
^
55+
source.ts meta.class.ts
56+
^
57+
source.ts meta.class.ts entity.name.type.class.ts
58+
^
59+
source.ts meta.class.ts
60+
^^^^^^^
61+
source.ts meta.class.ts storage.modifier.ts
62+
^
63+
source.ts meta.class.ts
64+
^
65+
source.ts meta.class.ts entity.other.inherited-class.ts
66+
^
67+
source.ts meta.class.ts
68+
^
69+
source.ts meta.class.ts punctuation.definition.block.ts
70+
^^
71+
source.ts meta.class.ts
72+
>}
73+
^
74+
source.ts meta.class.ts punctuation.definition.block.ts

tests/cases/Issue526.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if (a++ < b) {
2+
}
3+
4+
export class A extends B {
5+
}

0 commit comments

Comments
 (0)