File tree Expand file tree Collapse file tree 1 file changed +8
-18
lines changed
Expand file tree Collapse file tree 1 file changed +8
-18
lines changed Original file line number Diff line number Diff line change @@ -234,18 +234,8 @@ module.exports = {
234234 this . next ( ) ;
235235 }
236236
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 ] ;
249239
250240 const result = this . node ( "classconstant" ) ;
251241 const items = this . read_list (
@@ -266,14 +256,9 @@ module.exports = {
266256 ( this . version >= 700 && this . is ( "IDENTIFIER" ) )
267257 ) {
268258 constName = this . node ( "identifier" ) ;
269- name = this . text ( ) ;
259+ const name = this . text ( ) ;
270260 this . next ( ) ;
271261 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 ;
277262 } else {
278263 this . expect ( "IDENTIFIER" ) ;
279264 }
@@ -379,6 +364,11 @@ module.exports = {
379364 if ( nullable ) {
380365 this . next ( ) ;
381366 }
367+
368+ if ( this . peek ( ) === "=" ) {
369+ return [ false , null ] ;
370+ }
371+
382372 let type = this . read_types ( ) ;
383373 if ( nullable && ! type ) {
384374 this . raiseError (
You can’t perform that action at this time.
0 commit comments