File tree 1 file changed +8
-18
lines changed 1 file changed +8
-18
lines changed Original file line number Diff line number Diff line change @@ -234,18 +234,8 @@ module.exports = {
234
234
this . next ( ) ;
235
235
}
236
236
237
- let type = null ;
238
- let nullable = false ;
239
- if ( this . version >= 803 ) {
240
- [ nullable , type ] = this . read_optional_type ( ) ;
241
- }
242
- let name = null ;
243
-
244
- // read_optional_type can return a "type" even if the constant does not actually have a type.
245
- if ( type && type . kind === "name" && this . token === "=" ) {
246
- name = type . name ;
247
- type = null ;
248
- }
237
+ const [ nullable , type ] =
238
+ this . version >= 803 ? this . read_optional_type ( ) : [ false , null ] ;
249
239
250
240
const result = this . node ( "classconstant" ) ;
251
241
const items = this . read_list (
@@ -266,14 +256,9 @@ module.exports = {
266
256
( this . version >= 700 && this . is ( "IDENTIFIER" ) )
267
257
) {
268
258
constName = this . node ( "identifier" ) ;
269
- name = this . text ( ) ;
259
+ const name = this . text ( ) ;
270
260
this . next ( ) ;
271
261
constName = constName ( name ) ;
272
- }
273
- // read_optional_type is not always returning just a type but
274
- else if ( name ) {
275
- constName = this . node ( "identifier" ) ( name ) ;
276
- name = null ;
277
262
} else {
278
263
this . expect ( "IDENTIFIER" ) ;
279
264
}
@@ -379,6 +364,11 @@ module.exports = {
379
364
if ( nullable ) {
380
365
this . next ( ) ;
381
366
}
367
+
368
+ if ( this . peek ( ) === "=" ) {
369
+ return [ false , null ] ;
370
+ }
371
+
382
372
let type = this . read_types ( ) ;
383
373
if ( nullable && ! type ) {
384
374
this . raiseError (
You can’t perform that action at this time.
0 commit comments