Skip to content

Commit 04e7d1e

Browse files
authored
Require a space after the enum keyword (#143)
This stops us confusing enum declarations with enum values that happen to start `enum_foo`.
1 parent af235c7 commit 04e7d1e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

syntaxes/hack.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@
698698
]
699699
},
700700
{
701-
"begin": "(?i)^\\s*(enum)\\s*(class)\\s+([a-z0-9_]+)\\s*:?",
701+
"begin": "(?i)^\\s*(enum)\\s+(class)\\s+([a-z0-9_]+)\\s*:?",
702702
"beginCaptures": {
703703
"1": {
704704
"name": "storage.modifier.php"
@@ -723,7 +723,7 @@
723723
]
724724
},
725725
{
726-
"begin": "(?i)^\\s*(enum)\\s*([a-z0-9_]+)\\s*:?",
726+
"begin": "(?i)^\\s*(enum)\\s+([a-z0-9_]+)\\s*:?",
727727
"beginCaptures": {
728728
"1": {
729729
"name": "storage.type.enum.php"

syntaxes/test/enums.hack

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ enum SimpleEnum: int as arraykey {
22
X = 1;
33
Y = 2;
44
Z = 3;
5+
ENUM_FOO = 1;
6+
ENUM_CLASS_BAR = 2;
57
}
68

79
enum ComplicatedEnum: classname<Foo> as classname<Bar> {}

0 commit comments

Comments
 (0)