mirror of
https://github.com/golang/go
synced 2024-11-19 06:04:39 -07:00
079dfdcac0
6 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Robert Griesemer
|
8f19394b62 |
cmd/compile/internal/types2: refactor untyped conversions
Based on https://golang.org/cl/284256 for go/types. Brings this code more in line with go/types. Adjusted various tests to match new error messages which generally are now better: for assignment errors, instead of a generic "cannot convert" we now say "cannot use" followed by a clearer reason as to why not. Major differences to go/types with respect to the changed files: - Some of the new code now returns error codes, but they are only used internally for now, and not reported with errors. - go/types does not "convert" untyped nil values to target types, but here we do. This is unchanged from how types2 handled this before this CL. Change-Id: If45336d7ee679ece100f6d9d9f291a6ea55004d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/302757 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> |
||
Robert Griesemer
|
53c4c17b09 |
[dev.typeparams] all: merge dev.regabi into dev.typeparams
The files below had conflicts that required manual resolution. The unresolved conflict in noder.go was just in the import declaration (trivial). All the other conflicts are in tests where the ERROR regex patterns changed to accomodate gccgo error messages (incoming from dev.regabi), and to accomodate types2 in dev.typeparams. They were resolved by accepting the dev.regabi changes (so as not to lose them) and then by re- applying whatever changes needed to make them pass with types2. Finally, the new test mainsig.go was excluded from run.go when using types2 due to issue #43308. src/cmd/compile/internal/gc/noder.go test/fixedbugs/bug13343.go test/fixedbugs/bug462.go test/fixedbugs/issue10975.go test/fixedbugs/issue11326.go test/fixedbugs/issue11361.go test/fixedbugs/issue11371.go test/fixedbugs/issue11674.go test/fixedbugs/issue13365.go test/fixedbugs/issue13471.go test/fixedbugs/issue14136.go test/fixedbugs/issue14321.go test/fixedbugs/issue14729.go test/fixedbugs/issue15898.go test/fixedbugs/issue16439.go test/fixedbugs/issue17588.go test/fixedbugs/issue19323.go test/fixedbugs/issue19482.go test/fixedbugs/issue19880.go test/fixedbugs/issue20185.go test/fixedbugs/issue20227.go test/fixedbugs/issue20415.go test/fixedbugs/issue20749.go test/fixedbugs/issue22794.go test/fixedbugs/issue22822.go test/fixedbugs/issue22921.go test/fixedbugs/issue23823.go test/fixedbugs/issue25727.go test/fixedbugs/issue26616.go test/fixedbugs/issue28079c.go test/fixedbugs/issue28450.go test/fixedbugs/issue30085.go test/fixedbugs/issue30087.go test/fixedbugs/issue35291.go test/fixedbugs/issue38745.go test/fixedbugs/issue41247.go test/fixedbugs/issue41440.go test/fixedbugs/issue41500.go test/fixedbugs/issue4215.go test/fixedbugs/issue6402.go test/fixedbugs/issue6772.go test/fixedbugs/issue7129.go test/fixedbugs/issue7150.go test/fixedbugs/issue7153.go test/fixedbugs/issue7310.go test/fixedbugs/issue8183.go test/fixedbugs/issue8385.go test/fixedbugs/issue8438.go test/fixedbugs/issue8440.go test/fixedbugs/issue8507.go test/fixedbugs/issue9370.go test/fixedbugs/issue9521.go Change-Id: I26e6e326fde6e3fca5400711a253834d710ab7f4 |
||
Ian Lance Taylor
|
412dc2f4d3 |
test: adjust issue11371 to fit in required precision
The language spec only requires that floating point values be represented with 256 bits, which is about 1e75. The issue11371 test was assuming that the compiler could represent 1e100. Adjusting the test so that it only assumes 256 bits of precision still keeps the test valid, and permits it to pass when using the gofrontend. Change-Id: I9d1006e9adc9438277f4b8002488c912e5d61cc1 Reviewed-on: https://go-review.googlesource.com/c/go/+/278116 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> |
||
Ian Lance Taylor
|
6d2b3351f6 |
test: match gofrontend error messages
fixedbugs/bug13343.go:10:12: error: initialization expressions for ‘b’ and ‘c’ depend upon each other fixedbugs/bug13343.go:11:9: note: ‘c’ defined here fixedbugs/bug13343.go:11:9: error: initialization expression for ‘c’ depends upon itself fixedbugs/bug13343.go:11:9: error: initialization expressions for ‘c’ and ‘b’ depend upon each other fixedbugs/bug13343.go:10:12: note: ‘b’ defined here fixedbugs/issue10700.dir/test.go:24:10: error: reference to method ‘Do’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:25:10: error: reference to method ‘do’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:27:10: error: reference to method ‘Dont’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:28:13: error: reference to undefined field or method ‘Dont’ fixedbugs/issue10700.dir/test.go:31:10: error: reference to undefined field or method ‘do’ fixedbugs/issue10700.dir/test.go:33:13: error: reference to undefined field or method ‘do’ fixedbugs/issue10700.dir/test.go:34:10: error: reference to undefined field or method ‘Dont’ fixedbugs/issue10700.dir/test.go:35:13: error: reference to undefined field or method ‘Dont’ fixedbugs/issue10700.dir/test.go:37:10: error: reference to method ‘Do’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:38:10: error: reference to method ‘do’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:40:13: error: reference to undefined field or method ‘do’ fixedbugs/issue10700.dir/test.go:41:10: error: reference to method ‘Dont’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:42:13: error: reference to undefined field or method ‘Dont’ fixedbugs/issue10700.dir/test.go:43:10: error: reference to method ‘secret’ in type that is pointer to interface, not interface fixedbugs/issue10700.dir/test.go:44:13: error: reference to unexported field or method ‘secret’ fixedbugs/issue10975.go:13:9: error: interface contains embedded non-interface fixedbugs/issue11326.go:26:17: error: floating-point constant overflow fixedbugs/issue11326.go:27:17: error: floating-point constant overflow fixedbugs/issue11326.go:28:17: error: floating-point constant overflow fixedbugs/issue11361.go:9:11: error: import file ‘fmt’ not found fixedbugs/issue11361.go:11:11: error: reference to undefined name ‘fmt’ fixedbugs/issue11371.go:12:15: error: floating-point constant truncated to integer fixedbugs/issue11371.go:13:15: error: integer constant overflow fixedbugs/issue11371.go:17:15: error: floating-point constant truncated to integer fixedbugs/issue11590.go:9:17: error: integer constant overflow fixedbugs/issue11590.go:9:17: error: integer constant overflow fixedbugs/issue11590.go:10:22: error: complex real part overflow fixedbugs/issue11590.go:10:22: error: complex real part overflow fixedbugs/issue11590.go:11:23: error: complex real part overflow fixedbugs/issue11590.go:11:23: error: complex real part overflow fixedbugs/issue11590.go:9:19: error: integer constant overflow fixedbugs/issue11590.go:10:24: error: complex real part overflow fixedbugs/issue11590.go:11:25: error: complex real part overflow fixedbugs/issue11610.go:11:7: error: import path is empty fixedbugs/issue11610.go:12:4: error: invalid character 0x3f in input file fixedbugs/issue11610.go:14:1: error: expected identifier fixedbugs/issue11610.go:14:1: error: expected type fixedbugs/issue11614.go:14:9: error: interface contains embedded non-interface fixedbugs/issue13248.go:13:1: error: expected operand fixedbugs/issue13248.go:13:1: error: missing ‘)’ fixedbugs/issue13248.go:12:5: error: reference to undefined name ‘foo’ fixedbugs/issue13266.go:10:8: error: package name must be an identifier fixedbugs/issue13266.go:10:8: error: expected ‘;’ or newline after package clause fixedbugs/issue13266.go:10:8: error: expected declaration fixedbugs/issue13273.go:50:18: error: expected ‘chan’ fixedbugs/issue13273.go:53:24: error: expected ‘chan’ fixedbugs/issue13274.go:11:58: error: expected ‘}’ fixedbugs/issue13365.go:14:19: error: index expression is negative fixedbugs/issue13365.go:15:21: error: index expression is negative fixedbugs/issue13365.go:16:22: error: index expression is negative fixedbugs/issue13365.go:19:13: error: some element keys in composite literal are out of range fixedbugs/issue13365.go:22:19: error: incompatible type for element 1 in composite literal fixedbugs/issue13365.go:23:21: error: incompatible type for element 1 in composite literal fixedbugs/issue13365.go:24:22: error: incompatible type for element 1 in composite literal fixedbugs/issue13415.go:14:5: error: redefinition of ‘x’ fixedbugs/issue13415.go:14:5: note: previous definition of ‘x’ was here fixedbugs/issue13415.go:14:5: error: ‘x’ declared but not used fixedbugs/issue13471.go:12:25: error: floating-point constant truncated to integer fixedbugs/issue13471.go:13:25: error: floating-point constant truncated to integer fixedbugs/issue13471.go:14:25: error: floating-point constant truncated to integer fixedbugs/issue13471.go:15:24: error: floating-point constant truncated to integer fixedbugs/issue13471.go:16:23: error: floating-point constant truncated to integer fixedbugs/issue13471.go:18:26: error: floating-point constant truncated to integer fixedbugs/issue13471.go:19:26: error: floating-point constant truncated to integer fixedbugs/issue13471.go:20:26: error: floating-point constant truncated to integer fixedbugs/issue13471.go:21:25: error: floating-point constant truncated to integer fixedbugs/issue13471.go:22:24: error: floating-point constant truncated to integer fixedbugs/issue13471.go:24:24: error: floating-point constant truncated to integer fixedbugs/issue13821b.go:18:12: error: incompatible types in binary expression fixedbugs/issue13821b.go:19:13: error: incompatible types in binary expression fixedbugs/issue13821b.go:20:13: error: incompatible types in binary expression fixedbugs/issue13821b.go:21:13: error: incompatible types in binary expression fixedbugs/issue13821b.go:22:13: error: incompatible types in binary expression fixedbugs/issue13821b.go:24:12: error: incompatible types in binary expression fixedbugs/issue14006.go:24:18: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue14006.go:30:18: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue14006.go:37:22: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue14006.go:43:22: error: expected ‘;’ or ‘}’ or newline fixedbugs/issue14006.go:59:17: note: previous definition of ‘labelname’ was here fixedbugs/issue14006.go:64:17: error: label ‘labelname’ already defined fixedbugs/issue14006.go:24:17: error: value computed is not used fixedbugs/issue14006.go:30:17: error: value computed is not used fixedbugs/issue14006.go:37:20: error: value computed is not used fixedbugs/issue14006.go:43:20: error: value computed is not used fixedbugs/issue14006.go:59:17: error: label ‘labelname’ defined and not used fixedbugs/issue14010.go:13:14: error: invalid left hand side of assignment fixedbugs/issue14010.go:14:14: error: invalid left hand side of assignment fixedbugs/issue14010.go:14:9: error: invalid use of type fixedbugs/issue14321.go:30:10: error: method ‘F’ is ambiguous in type ‘C’ fixedbugs/issue14321.go:31:10: error: ‘G’ is ambiguous via ‘A’ and ‘B’ fixedbugs/issue14321.go:33:10: error: type ‘C’ has no method ‘I’ fixedbugs/issue8183.go:12:14: error: integer constant overflow fixedbugs/issue9036.go:21:12: error: invalid prefix for floating constant fixedbugs/issue9036.go:22:12: error: invalid prefix for floating constant fixedbugs/issue9076.go:14:5: error: incompatible type in initialization (cannot use type uintptr as type int32) fixedbugs/issue9076.go:15:5: error: incompatible type in initialization (cannot use type uintptr as type int32) For issue9083.go avoid an error about a variable that is set but not used. fixedbugs/issue9370.go:105:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:106:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:107:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:108:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:109:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:110:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:112:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:113:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:114:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:115:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:116:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:117:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:119:13: error: cannot use ‘_’ as value fixedbugs/issue9370.go:119:18: error: cannot use ‘_’ as value fixedbugs/issue9370.go:36:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:39:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:43:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:46:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:50:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:53:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:56:15: error: incompatible types in binary expression fixedbugs/issue9370.go:57:15: error: incompatible types in binary expression fixedbugs/issue9370.go:58:15: error: incompatible types in binary expression fixedbugs/issue9370.go:59:15: error: incompatible types in binary expression fixedbugs/issue9370.go:60:15: error: incompatible types in binary expression fixedbugs/issue9370.go:61:15: error: incompatible types in binary expression fixedbugs/issue9370.go:65:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:68:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:70:15: error: incompatible types in binary expression fixedbugs/issue9370.go:71:15: error: incompatible types in binary expression fixedbugs/issue9370.go:72:15: error: incompatible types in binary expression fixedbugs/issue9370.go:73:15: error: incompatible types in binary expression fixedbugs/issue9370.go:74:15: error: incompatible types in binary expression fixedbugs/issue9370.go:75:15: error: incompatible types in binary expression fixedbugs/issue9370.go:77:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:78:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:79:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:80:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:81:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:82:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:84:15: error: incompatible types in binary expression fixedbugs/issue9370.go:85:15: error: incompatible types in binary expression fixedbugs/issue9370.go:86:15: error: incompatible types in binary expression fixedbugs/issue9370.go:87:15: error: incompatible types in binary expression fixedbugs/issue9370.go:88:15: error: incompatible types in binary expression fixedbugs/issue9370.go:89:15: error: incompatible types in binary expression fixedbugs/issue9370.go:91:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:92:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:93:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:94:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:95:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:96:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:98:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:99:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go💯15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:101:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:102:15: error: invalid operation (func can only be compared to nil) fixedbugs/issue9370.go:103:15: error: invalid comparison of non-ordered type fixedbugs/issue9370.go:121:15: error: incompatible types in binary expression fixedbugs/issue9370.go:122:15: error: incompatible types in binary expression fixedbugs/issue9370.go:123:15: error: incompatible types in binary expression fixedbugs/issue9370.go:124:15: error: incompatible types in binary expression Change-Id: I4089de4919112b08f5f2bbec20f84fcc7dbe3955 Reviewed-on: https://go-review.googlesource.com/c/go/+/276832 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> |
||
Robert Griesemer
|
02820d61a9 |
[dev.typeparams] test: enable some more errorcheck tests
Change-Id: I103e3eeacd5b11efd63c965482a626878ba5ac81 Reviewed-on: https://go-review.googlesource.com/c/go/+/275216 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> |
||
Alberto Donizetti
|
e99dafc4a8 |
cmd/compile: fix misleading "truncated to int" messages
When defining an int const, the compiler tries to cast the RHS expression to int. The cast may fail for three reasons: 1. expr is an integer constant that overflows int 2. expr is a floating point constant 3. expr is a complex constant, or not a number In the second case, in order to print a sensible error message, we must distinguish between a floating point constant that should be included in the error message and a floating point constant that cannot be reasonably formatted for inclusion in an error message. For example, in: const a int = 1.1 const b int = 1 + 1e-100 a is in the former group, while b is in the latter, since the floating point value resulting from the evaluation of the rhs of the assignment (1.00...01) is too long to be fully printed in an error message, and cannot be shortened without making the error message misleading (rounding or truncating it would result in a "1", which looks like an integer constant, and it makes little sense in an error message about an invalid floating point expression). To fix this problem, we try to format the float value using fconv (which is used by the error reporting mechanism to format float arguments), and then parse the resulting string back to a big.Float. If the result is an integer, we assume that expr is a float value that cannot be reasonably be formatted as a string, and we emit an error message that does not include its string representation. Also, change the error message for overflows to a more conservative "integer too large", which does not mention overflows that are only caused by an internal implementation restriction. Also, change (*Mpint) SetFloat so that it returns a bool (instead of 0/-1 for success/failure). Fixes #11371 Change-Id: Ibbc73e2ed2eaf41f07827b0649d0eb637150ecaa Reviewed-on: https://go-review.googlesource.com/35411 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> |