Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 4 of 4 for HasNil (0.31 sec)

  1. src/cmd/compile/internal/types2/predicates.go

    	}
    	return false
    }
    
    // hasNil reports whether type t includes the nil value.
    func hasNil(t Type) bool {
    	switch u := under(t).(type) {
    	case *Basic:
    		return u.kind == UnsafePointer
    	case *Slice, *Pointer, *Signature, *Map, *Chan:
    		return true
    	case *Interface:
    		return !isTypeParam(t) || u.typeSet().underIs(func(u Type) bool {
    			return u != nil && hasNil(u)
    		})
    	}
    	return false
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 03:01:18 UTC 2024
    - 17.5K bytes
    - Viewed (0)
  2. src/go/types/predicates.go

    	}
    	return false
    }
    
    // hasNil reports whether type t includes the nil value.
    func hasNil(t Type) bool {
    	switch u := under(t).(type) {
    	case *Basic:
    		return u.kind == UnsafePointer
    	case *Slice, *Pointer, *Signature, *Map, *Chan:
    		return true
    	case *Interface:
    		return !isTypeParam(t) || u.typeSet().underIs(func(u Type) bool {
    			return u != nil && hasNil(u)
    		})
    	}
    	return false
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 03:01:18 UTC 2024
    - 17.6K bytes
    - Viewed (0)
  3. src/go/types/stmt.go

    			// By checking assignment of x to an invisible temporary
    			// (as a compiler would), we get all the relevant checks.
    			check.assignment(&x, nil, "switch expression")
    			if x.mode != invalid && !Comparable(x.typ) && !hasNil(x.typ) {
    				check.errorf(&x, InvalidExprSwitch, "cannot switch on %s (%s is not comparable)", &x, x.typ)
    				x.mode = invalid
    			}
    		} else {
    			// spec: "A missing switch expression is
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 30 19:19:55 UTC 2024
    - 30.6K bytes
    - Viewed (0)
  4. src/cmd/compile/internal/types2/stmt.go

    		// By checking assignment of x to an invisible temporary
    		// (as a compiler would), we get all the relevant checks.
    		check.assignment(&x, nil, "switch expression")
    		if x.mode != invalid && !Comparable(x.typ) && !hasNil(x.typ) {
    			check.errorf(&x, InvalidExprSwitch, "cannot switch on %s (%s is not comparable)", &x, x.typ)
    			x.mode = invalid
    		}
    	} else {
    		// spec: "A missing switch expression is
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 30 19:19:55 UTC 2024
    - 30.7K bytes
    - Viewed (0)
Back to top