@@ -78,6 +78,7 @@ func extractEnumNamedValues(chType Type) (typ string, values []string, indexes [
78
78
var foundValueLen int
79
79
var skippedValueTokens []int
80
80
var indexFound bool
81
+ var valueFound bool
81
82
var valueIndex = 0
82
83
83
84
for c := 0 ; c < len (src ); c ++ {
@@ -104,6 +105,7 @@ func extractEnumNamedValues(chType Type) (typ string, values []string, indexes [
104
105
case token == '\'' && stringOpen :
105
106
stringOpen = false
106
107
foundValueLen = c - foundValueOffset
108
+ valueFound = true
107
109
break
108
110
// escape character, skip the next character
109
111
case token == '\\' && stringOpen :
@@ -112,10 +114,9 @@ func extractEnumNamedValues(chType Type) (typ string, values []string, indexes [
112
114
break
113
115
// capture optional index. `=` token is followed with an integer index
114
116
case token == '=' && ! stringOpen :
115
- if foundValueLen == 0 {
117
+ if ! valueFound {
116
118
return
117
119
}
118
-
119
120
indexStart := c + 1
120
121
// find the end of the index, it's either a comma or a closing bracket
121
122
for _ , token := range src [indexStart :] {
@@ -134,10 +135,9 @@ func extractEnumNamedValues(chType Type) (typ string, values []string, indexes [
134
135
break
135
136
// capture the value and index when a comma or closing bracket is found
136
137
case (token == ',' || token == ')' ) && ! stringOpen :
137
- if foundValueLen == 0 {
138
+ if ! valueFound {
138
139
return
139
140
}
140
-
141
141
// if no index was found for current value, increment the value index
142
142
// e.g. Enum8('a','b') is equivalent to Enum8('a'=1,'b'=2)
143
143
// or Enum8('a'=3,'b') is equivalent to Enum8('a'=3,'b'=4)
@@ -160,6 +160,7 @@ func extractEnumNamedValues(chType Type) (typ string, values []string, indexes [
160
160
indexes = append (indexes , valueIndex )
161
161
values = append (values , string (foundName ))
162
162
indexFound = false
163
+ valueFound = false
163
164
break
164
165
}
165
166
}
0 commit comments