})
}
+// The following is temporary scaffolding to get types2 typechecker
+// up and running against the existing test cases. The explicitly
+// listed files don't pass yet, usually because the error messages
+// are slightly different (this list is not complete). Any errorcheck
+// tests that require output from analysis phases past initial type-
+// checking are also excluded since these phases are not running yet.
+// We can get rid of this code once types2 is fully plugged in.
+
// List of files that the compiler cannot errorcheck with the new typechecker (compiler -G option).
// Temporary scaffolding until we pass all the tests at which point this map can be removed.
-var excluded = map[string]bool{
- "complit1.go": true, // types2 reports extra errors
- "const2.go": true, // types2 not run after syntax errors
- "ddd1.go": true, // issue #42987
- "directive.go": true, // misplaced compiler directive checks
- "float_lit3.go": true, // types2 reports extra errors
- "import1.go": true, // types2 reports extra errors
- "import5.go": true, // issue #42988
- "import6.go": true, // issue #43109
- "initializerr.go": true, // types2 reports extra errors
- "linkname2.go": true, // error reported by noder (not running for types2 errorcheck test)
- "notinheap.go": true, // types2 doesn't report errors about conversions that are invalid due to //go:notinheap
- "shift1.go": true, // issue #42989
- "typecheck.go": true, // invalid function is not causing errors when called
- "writebarrier.go": true, // correct diagnostics, but different lines (probably irgen's fault)
-
- "fixedbugs/bug176.go": true, // types2 reports all errors (pref: types2)
- "fixedbugs/bug195.go": true, // types2 reports slightly different (but correct) bugs
- "fixedbugs/bug228.go": true, // types2 not run after syntax errors
- "fixedbugs/bug231.go": true, // types2 bug? (same error reported twice)
- "fixedbugs/bug255.go": true, // types2 reports extra errors
- "fixedbugs/bug351.go": true, // types2 reports extra errors
- "fixedbugs/bug374.go": true, // types2 reports extra errors
- "fixedbugs/bug385_32.go": true, // types2 doesn't produce missing error "type .* too large" (32-bit specific)
- "fixedbugs/bug388.go": true, // types2 not run due to syntax errors
- "fixedbugs/bug412.go": true, // types2 produces a follow-on error
-
- "fixedbugs/issue11590.go": true, // types2 doesn't report a follow-on error (pref: types2)
- "fixedbugs/issue11610.go": true, // types2 not run after syntax errors
- "fixedbugs/issue11614.go": true, // types2 reports an extra error
- "fixedbugs/issue13415.go": true, // declared but not used conflict
- "fixedbugs/issue14520.go": true, // missing import path error by types2
- "fixedbugs/issue16428.go": true, // types2 reports two instead of one error
- "fixedbugs/issue17038.go": true, // types2 doesn't report a follow-on error (pref: types2)
- "fixedbugs/issue17645.go": true, // multiple errors on same line
- "fixedbugs/issue18331.go": true, // missing error about misuse of //go:noescape (irgen needs code from noder)
- "fixedbugs/issue18393.go": true, // types2 not run after syntax errors
- "fixedbugs/issue19012.go": true, // multiple errors on same line
- "fixedbugs/issue20233.go": true, // types2 reports two instead of one error (pref: compiler)
- "fixedbugs/issue20245.go": true, // types2 reports two instead of one error (pref: compiler)
- "fixedbugs/issue20250.go": true, // correct diagnostics, but different lines (probably irgen's fault)
- "fixedbugs/issue21979.go": true, // types2 doesn't report a follow-on error (pref: types2)
- "fixedbugs/issue23732.go": true, // types2 reports different (but ok) line numbers
- "fixedbugs/issue25958.go": true, // types2 doesn't report a follow-on error (pref: types2)
- "fixedbugs/issue28079b.go": true, // types2 reports follow-on errors
- "fixedbugs/issue28268.go": true, // types2 reports follow-on errors
- "fixedbugs/issue33460.go": true, // types2 reports alternative positions in separate error
- "fixedbugs/issue41575.go": true, // types2 reports alternative positions in separate error
- "fixedbugs/issue42058a.go": true, // types2 doesn't report "channel element type too large"
- "fixedbugs/issue42058b.go": true, // types2 doesn't report "channel element type too large"
- "fixedbugs/issue4232.go": true, // types2 reports (correct) extra errors
- "fixedbugs/issue4452.go": true, // types2 reports (correct) extra errors
- "fixedbugs/issue5609.go": true, // types2 needs a better error message
- "fixedbugs/issue6889.go": true, // types2 can handle this without constant overflow
- "fixedbugs/issue7525.go": true, // types2 reports init cycle error on different line - ok otherwise
- "fixedbugs/issue7525b.go": true, // types2 reports init cycle error on different line - ok otherwise
- "fixedbugs/issue7525c.go": true, // types2 reports init cycle error on different line - ok otherwise
- "fixedbugs/issue7525d.go": true, // types2 reports init cycle error on different line - ok otherwise
- "fixedbugs/issue7525e.go": true, // types2 reports init cycle error on different line - ok otherwise
- "fixedbugs/issue46749.go": true, // types2 reports can not convert error instead of type mismatched
+var types2Failures = setOf(
+ "directive.go", // misplaced compiler directive checks
+ "float_lit3.go", // types2 reports extra errors
+ "import1.go", // types2 reports extra errors
+ "import6.go", // issue #43109
+ "initializerr.go", // types2 reports extra errors
+ "linkname2.go", // error reported by noder (not running for types2 errorcheck test)
+ "notinheap.go", // types2 doesn't report errors about conversions that are invalid due to //go:notinheap
+ "shift1.go", // issue #42989
+ "typecheck.go", // invalid function is not causing errors when called
+
+ "interface/private.go", // types2 phrases errors differently (doesn't use non-spec "private" term)
+
+ "fixedbugs/bug176.go", // types2 reports all errors (pref: types2)
+ "fixedbugs/bug195.go", // types2 reports slightly different (but correct) bugs
+ "fixedbugs/bug228.go", // types2 doesn't run when there are syntax errors
+ "fixedbugs/bug231.go", // types2 bug? (same error reported twice)
+ "fixedbugs/bug255.go", // types2 reports extra errors
+ "fixedbugs/bug374.go", // types2 reports extra errors
+ "fixedbugs/bug388.go", // types2 not run due to syntax errors
+ "fixedbugs/bug412.go", // types2 produces a follow-on error
+
+ "fixedbugs/issue10700.go", // types2 reports ok hint, but does not match regexp
+ "fixedbugs/issue11590.go", // types2 doesn't report a follow-on error (pref: types2)
+ "fixedbugs/issue11610.go", // types2 not run after syntax errors
+ "fixedbugs/issue11614.go", // types2 reports an extra error
+ "fixedbugs/issue14520.go", // missing import path error by types2
+ "fixedbugs/issue16133.go", // types2 doesn't use package path for qualified identifiers when package name is ambiguous
+ "fixedbugs/issue16428.go", // types2 reports two instead of one error
+ "fixedbugs/issue17038.go", // types2 doesn't report a follow-on error (pref: types2)
+ "fixedbugs/issue17645.go", // multiple errors on same line
+ "fixedbugs/issue18331.go", // missing error about misuse of //go:noescape (irgen needs code from noder)
+ "fixedbugs/issue18419.go", // types2 reports
+ "fixedbugs/issue19012.go", // multiple errors on same line
+ "fixedbugs/issue20233.go", // types2 reports two instead of one error (pref: compiler)
+ "fixedbugs/issue20245.go", // types2 reports two instead of one error (pref: compiler)
+ "fixedbugs/issue21979.go", // types2 doesn't report a follow-on error (pref: types2)
+ "fixedbugs/issue23732.go", // types2 reports different (but ok) line numbers
+ "fixedbugs/issue25958.go", // types2 doesn't report a follow-on error (pref: types2)
+ "fixedbugs/issue28079b.go", // types2 reports follow-on errors
+ "fixedbugs/issue28268.go", // types2 reports follow-on errors
+ "fixedbugs/issue31053.go", // types2 reports "unknown field" instead of "cannot refer to unexported field"
+ "fixedbugs/issue33460.go", // types2 reports alternative positions in separate error
+ "fixedbugs/issue42058a.go", // types2 doesn't report "channel element type too large"
+ "fixedbugs/issue42058b.go", // types2 doesn't report "channel element type too large"
+ "fixedbugs/issue4232.go", // types2 reports (correct) extra errors
+ "fixedbugs/issue4452.go", // types2 reports (correct) extra errors
+ "fixedbugs/issue4510.go", // types2 reports different (but ok) line numbers
++ "fixedbugs/issue47201.go", // types2 spells the error message differently
+ "fixedbugs/issue5609.go", // types2 needs a better error message
+ "fixedbugs/issue7525b.go", // types2 reports init cycle error on different line - ok otherwise
+ "fixedbugs/issue7525c.go", // types2 reports init cycle error on different line - ok otherwise
+ "fixedbugs/issue7525d.go", // types2 reports init cycle error on different line - ok otherwise
+ "fixedbugs/issue7525e.go", // types2 reports init cycle error on different line - ok otherwise
+ "fixedbugs/issue7525.go", // types2 reports init cycle error on different line - ok otherwise
+)
+
+var types2Failures32Bit = setOf(
+ "printbig.go", // large untyped int passed to print (32-bit)
+ "fixedbugs/bug114.go", // large untyped int passed to println (32-bit)
+ "fixedbugs/issue23305.go", // large untyped int passed to println (32-bit)
+ "fixedbugs/bug385_32.go", // types2 doesn't produce missing error "type .* too large" (32-bit specific)
+)
+
+var g3Failures = setOf(
+ "writebarrier.go", // correct diagnostics, but different lines (probably irgen's fault)
+
+ "typeparam/nested.go", // -G=3 doesn't support function-local types with generics
+
+ "typeparam/mdempsky/4.go", // -G=3 can't export functions with labeled breaks in loops
+)
+
+var unifiedFailures = setOf(
+ "closure3.go", // unified IR numbers closures differently than -d=inlfuncswithclosures
+ "escape4.go", // unified IR can inline f5 and f6; test doesn't expect this
+ "inline.go", // unified IR reports function literal diagnostics on different lines than -d=inlfuncswithclosures
+
+ "fixedbugs/issue42284.go", // prints "T(0) does not escape", but test expects "a.I(a.T(0)) does not escape"
+ "fixedbugs/issue7921.go", // prints "… escapes to heap", but test expects "string(…) escapes to heap"
+)
+
+func setOf(keys ...string) map[string]bool {
+ m := make(map[string]bool, len(keys))
+ for _, key := range keys {
+ m[key] = true
+ }
+ return m
+}
+
+// splitQuoted splits the string s around each instance of one or more consecutive
+// white space characters while taking into account quotes and escaping, and
+// returns an array of substrings of s or an empty list if s contains only white space.
+// Single quotes and double quotes are recognized to prevent splitting within the
+// quoted region, and are removed from the resulting substrings. If a quote in s
+// isn't closed err will be set and r will have the unclosed argument as the
+// last element. The backslash is used for escaping.
+//
+// For example, the following string:
+//
+// a b:"c d" 'e''f' "g\""
+//
+// Would be parsed as:
+//
+// []string{"a", "b:c d", "ef", `g"`}
+//
+// [copied from src/go/build/build.go]
+func splitQuoted(s string) (r []string, err error) {
+ var args []string
+ arg := make([]rune, len(s))
+ escaped := false
+ quoted := false
+ quote := '\x00'
+ i := 0
+ for _, rune := range s {
+ switch {
+ case escaped:
+ escaped = false
+ case rune == '\\':
+ escaped = true
+ continue
+ case quote != '\x00':
+ if rune == quote {
+ quote = '\x00'
+ continue
+ }
+ case rune == '"' || rune == '\'':
+ quoted = true
+ quote = rune
+ continue
+ case unicode.IsSpace(rune):
+ if quoted || i > 0 {
+ quoted = false
+ args = append(args, string(arg[:i]))
+ i = 0
+ }
+ continue
+ }
+ arg[i] = rune
+ i++
+ }
+ if quoted || i > 0 {
+ args = append(args, string(arg[:i]))
+ }
+ if quote != 0 {
+ err = errors.New("unclosed quote")
+ } else if escaped {
+ err = errors.New("unfinished escaping")
+ }
+ return args, err
}