@@ -386,6 +386,35 @@ function initSearch(rawSearchIndex) {
386386 if ( query . literalSearch && parserState . totalElems - parserState . genericsElems > 0 ) {
387387 throw [ "You cannot have more than one element if you use quotes" ] ;
388388 }
389+ const typeFilter = parserState . typeFilter ;
390+ parserState . typeFilter = null ;
391+ if ( name === "!" ) {
392+ if ( typeFilter !== null && typeFilter !== "primitive" ) {
393+ throw [
394+ "Invalid search type: primitive never type " ,
395+ "!" ,
396+ " and " ,
397+ typeFilter ,
398+ " both specified" ,
399+ ] ;
400+ }
401+ if ( generics . length !== 0 ) {
402+ throw [
403+ "Never type " ,
404+ "!" ,
405+ " does not accept generic parameters" ,
406+ ] ;
407+ }
408+ return {
409+ name : "never" ,
410+ id : - 1 ,
411+ fullPath : [ "never" ] ,
412+ pathWithoutLast : [ ] ,
413+ pathLast : "never" ,
414+ generics : [ ] ,
415+ typeFilter : "primitive" ,
416+ } ;
417+ }
389418 const pathSegments = name . split ( "::" ) ;
390419 if ( pathSegments . length > 1 ) {
391420 for ( let i = 0 , len = pathSegments . length ; i < len ; ++ i ) {
@@ -399,6 +428,13 @@ function initSearch(rawSearchIndex) {
399428 }
400429 throw [ "Unexpected " , "::::" ] ;
401430 }
431+
432+ if ( pathSegment === "!" ) {
433+ pathSegments [ i ] = "never" ;
434+ if ( i !== 0 ) {
435+ throw [ "Never type " , "!" , " is not associated item" ] ;
436+ }
437+ }
402438 }
403439 }
404440 // In case we only have something like `<p>`, there is no name.
@@ -409,8 +445,6 @@ function initSearch(rawSearchIndex) {
409445 if ( isInGenerics ) {
410446 parserState . genericsElems += 1 ;
411447 }
412- const typeFilter = parserState . typeFilter ;
413- parserState . typeFilter = null ;
414448 return {
415449 name : name ,
416450 id : - 1 ,
@@ -459,10 +493,11 @@ function initSearch(rawSearchIndex) {
459493 break ;
460494 }
461495 if ( foundExclamation !== - 1 ) {
462- if ( start <= ( end - 2 ) ) {
496+ if ( foundExclamation !== start &&
497+ isIdentCharacter ( parserState . userQuery [ foundExclamation - 1 ] )
498+ ) {
463499 throw [ "Cannot have associated items in macros" ] ;
464500 } else {
465- // if start == end - 1, we got the never type
466501 // while the never type has no associated macros, we still
467502 // can parse a path like that
468503 foundExclamation = - 1 ;
@@ -478,7 +513,10 @@ function initSearch(rawSearchIndex) {
478513 end = parserState . pos ;
479514 }
480515 // if start == end - 1, we got the never type
481- if ( foundExclamation !== - 1 && start <= ( end - 2 ) ) {
516+ if ( foundExclamation !== - 1 &&
517+ foundExclamation !== start &&
518+ isIdentCharacter ( parserState . userQuery [ foundExclamation - 1 ] )
519+ ) {
482520 if ( parserState . typeFilter === null ) {
483521 parserState . typeFilter = "macro" ;
484522 } else if ( parserState . typeFilter !== "macro" ) {
0 commit comments