@@ -386,6 +386,35 @@ function initSearch(rawSearchIndex) {
386
386
if ( query . literalSearch && parserState . totalElems - parserState . genericsElems > 0 ) {
387
387
throw [ "You cannot have more than one element if you use quotes" ] ;
388
388
}
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
+ }
389
418
const pathSegments = name . split ( "::" ) ;
390
419
if ( pathSegments . length > 1 ) {
391
420
for ( let i = 0 , len = pathSegments . length ; i < len ; ++ i ) {
@@ -399,6 +428,13 @@ function initSearch(rawSearchIndex) {
399
428
}
400
429
throw [ "Unexpected " , "::::" ] ;
401
430
}
431
+
432
+ if ( pathSegment === "!" ) {
433
+ pathSegments [ i ] = "never" ;
434
+ if ( i !== 0 ) {
435
+ throw [ "Never type " , "!" , " is not associated item" ] ;
436
+ }
437
+ }
402
438
}
403
439
}
404
440
// In case we only have something like `<p>`, there is no name.
@@ -409,8 +445,6 @@ function initSearch(rawSearchIndex) {
409
445
if ( isInGenerics ) {
410
446
parserState . genericsElems += 1 ;
411
447
}
412
- const typeFilter = parserState . typeFilter ;
413
- parserState . typeFilter = null ;
414
448
return {
415
449
name : name ,
416
450
id : - 1 ,
@@ -459,10 +493,11 @@ function initSearch(rawSearchIndex) {
459
493
break ;
460
494
}
461
495
if ( foundExclamation !== - 1 ) {
462
- if ( start <= ( end - 2 ) ) {
496
+ if ( foundExclamation !== start &&
497
+ isIdentCharacter ( parserState . userQuery [ foundExclamation - 1 ] )
498
+ ) {
463
499
throw [ "Cannot have associated items in macros" ] ;
464
500
} else {
465
- // if start == end - 1, we got the never type
466
501
// while the never type has no associated macros, we still
467
502
// can parse a path like that
468
503
foundExclamation = - 1 ;
@@ -478,7 +513,10 @@ function initSearch(rawSearchIndex) {
478
513
end = parserState . pos ;
479
514
}
480
515
// 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
+ ) {
482
520
if ( parserState . typeFilter === null ) {
483
521
parserState . typeFilter = "macro" ;
484
522
} else if ( parserState . typeFilter !== "macro" ) {
0 commit comments