Search Options

Results per page
Sort
Preferred Languages
Advance

Results 41 - 50 of 2,044 for IsSwitch (0.25 sec)

  1. test/fixedbugs/issue53635.go

    // license that can be found in the LICENSE file.
    
    package main
    
    func main() {
    	f[int]()
    }
    
    func f[T any]() {
    	switch []T(nil) {
    	case nil:
    	default:
    		panic("FAIL")
    	}
    
    	switch (func() T)(nil) {
    	case nil:
    	default:
    		panic("FAIL")
    	}
    
    	switch (map[int]T)(nil) {
    	case nil:
    	default:
    		panic("FAIL")
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Jul 08 12:57:49 UTC 2022
    - 423 bytes
    - Viewed (0)
  2. test/switch4.go

    // Verify that erroneous switch statements are detected by the compiler.
    // Does not compile.
    
    package main
    
    type I interface {
    	M()
    }
    
    func bad() {
    
    	i5 := 5
    	switch i5 {
    	case 5:
    		fallthrough // ERROR "cannot fallthrough final case in switch"
    	}
    }
    
    func good() {
    	var i interface{}
    	var s string
    
    	switch i {
    	case s:
    	}
    
    	switch s {
    	case i:
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Mar 15 04:35:09 UTC 2013
    - 526 bytes
    - Viewed (0)
  3. src/cmd/compile/internal/test/testdata/break_test.go

    	var n int
    	switch g {
    	case 0:
    		n = 1
    		switch h {
    		case 0:
    			n += 10
    			break
    		}
    		n = 2
    	}
    	return n
    }
    
    func switchLabeledInner_ssa() int {
    	var n int
    	switch g {
    	case 0:
    		n = 1
    	Done:
    		switch h {
    		case 0:
    			n += 10
    			break Done
    		}
    		n = 2
    	}
    	return n
    }
    
    func switchLabeledOuter_ssa() int {
    	var n int
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Dec 23 06:40:04 UTC 2020
    - 3.7K bytes
    - Viewed (0)
  4. test/fixedbugs/issue29562.go

    // license that can be found in the LICENSE file.
    
    // Triggers a double walk of the (inlined) switch in il
    
    package p
    
    func il(s string) string {
    	switch len(s) {
    	case 0:
    		return "zero"
    	case 1:
    		return "one"
    	}
    	return s
    }
    
    func f() {
    	var s string
    	var as []string
    	switch false && (s+"a"+as[0]+il(s)+as[0]+s == "") {
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Jan 04 21:51:37 UTC 2019
    - 449 bytes
    - Viewed (0)
  5. test/fixedbugs/bug373.go

    // Issue 873, 2162
    
    package foo
    
    func f(x interface{}) {
    	switch t := x.(type) {  // ERROR "declared and not used"
    	case int:
    	}
    }
    
    func g(x interface{}) {
    	switch t := x.(type) {
    	case int:
    	case float32:
    		println(t)
    	}
    }
    
    func h(x interface{}) {
    	switch t := x.(type) {
    	case int:
    	case float32:
    	default:
    		println(t)
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 27 21:10:19 UTC 2022
    - 502 bytes
    - Viewed (0)
  6. test/fixedbugs/issue25006.go

    // license that can be found in the LICENSE file.
    
    package p
    
    func spin() {
    	var i int
    	var b bool
    
    	switch 1 {
    	case 0:
    		i = 1
    	}
    	switch 1 {
    	case i:
    	default:
    		i = 1
    		b = !b && (b && !b) && b
    	}
    	switch false {
    	case false:
    		i = 3 + -i
    		switch 0 {
    		case 1 - i:
    		}
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 24 16:20:41 UTC 2018
    - 400 bytes
    - Viewed (0)
  7. test/fixedbugs/bug157.go

    func f() {}
    
    func main() {
    	x := 0;
    
    	// this compiles
    	switch x {
    	case 0: f();
    	default: f();
    	}
    
    	// this doesn't but it should
    	// (semicolons are not needed at the end of a statement list)
    	switch x {
    	case 0: f()
    	default: f()
    	}
    }
    
    
    /*
    bug157.go:20: syntax error near default
    bug157.go:20: first switch statement must be a case
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Sat Feb 18 21:15:42 UTC 2012
    - 524 bytes
    - Viewed (0)
  8. test/fixedbugs/issue20185.go

    // caused an internal compiler error.
    
    package p
    
    func F() {
    	switch t := nil.(type) { // ERROR "cannot type switch on non-interface value|not an interface"
    	default:
    		_ = t
    	}
    }
    
    const x = 1
    
    func G() {
    	switch t := x.(type) { // ERROR "cannot type switch on non-interface value|declared and not used|not an interface"
    	default:
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Sep 27 21:10:19 UTC 2022
    - 581 bytes
    - Viewed (0)
  9. src/internal/types/testdata/fixedbugs/issue42758.go

    package p
    
    func _[T any](x interface{}){
    	switch x.(type) {
    	case T: // ok to use a type parameter
    	case int:
    	}
    
    	switch x.(type) {
    	case T:
    	case T /* ERROR "duplicate case" */ :
    	}
    }
    
    type constraint interface {
    	~int
    }
    
    func _[T constraint](x interface{}){
    	switch x.(type) {
    	case T: // ok to use a type parameter even if type set contains int
    	case int:
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Jan 17 19:54:25 UTC 2023
    - 649 bytes
    - Viewed (0)
  10. src/math/cmplx/sin.go

    // Also tested by csin(casin(z)) = z.
    
    // Sin returns the sine of x.
    func Sin(x complex128) complex128 {
    	switch re, im := real(x), imag(x); {
    	case im == 0 && (math.IsInf(re, 0) || math.IsNaN(re)):
    		return complex(math.NaN(), im)
    	case math.IsInf(im, 0):
    		switch {
    		case re == 0:
    			return x
    		case math.IsInf(re, 0) || math.IsNaN(re):
    			return complex(math.NaN(), im)
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Nov 18 17:59:44 UTC 2022
    - 4.8K bytes
    - Viewed (0)
Back to top