New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/api: switch to using go/types instead of its own type checker #4538
Labels
Milestone
Comments
i think add an untyped exported symbol to any non-test file in src/pkg with initial value of false will trigger this. (e.g. `var VariableName = false`) this issue will be fixed when cmd/api make use of go/types to do proper type checking. For now, the following patch could temporarily fix this issue, but as this issue doesn't affect the official build, i'm inclined to leave this as is, and wait until go/types is ready. diff -r e61b6119272b src/cmd/api/goapi.go --- a/src/cmd/api/goapi.go Thu Dec 13 19:08:51 2012 +0800 +++ b/src/cmd/api/goapi.go Thu Dec 13 20:28:50 2012 +0800 @@ -558,6 +558,11 @@ token.IMAG: "complex128", } +var predeclaredType = map[string]string{ + "true": "bool", + "false": "bool", +} + var errTODO = errors.New("TODO") func (w *Walker) constValueType(vi interface{}) (string, error) { @@ -671,7 +676,11 @@ case *ast.Ident: node, _, ok := w.resolveName(v.Name) if !ok { - return "", fmt.Errorf("unresolved identifier: %q", v.Name) + typ, ok := predeclaredType[v.Name] + if !ok { + return "", fmt.Errorf("unresolved identifier: %q", v.Name) + } + return typ, nil } return w.varValueType(node) case *ast.BinaryExpr: |
Just as minux said, when I use a untyped exported symbol, this error occurs. like var ( Threshold = 0.001 Variance = 0.8 KMeansPP = false ) and there is a same question in go-sqlite http://code.google.com/p/gosqlite/issues/detail?id=20 Row = Errno(100) // /* sqlite3_step() has another row ready */ Done = Errno(101) // /* sqlite3_step() has finished executing */ //this will cause api check error Row error = Errno(100) // /* sqlite3_step() has another row ready */ Done error = Errno(101) // /* sqlite3_step() has finished executing */ //no problem |
I think we're at a point where the transition is fairly easy now. Call types.Check with the files belonging to the package and you get back a types.Package containing a types.Scope with all top-level objects. The set of the exported objects simply needs to be compared against the original set for this packages. |
Caveat: There's a showstopper at the moment, and that's the fact that a small handfull of std libs are not fully type checked yet due to errors in shift type checking which are (still) not fixed (i.e., I spoke too early on Jan 14). I am planning to look into this as the next thing. Once the entire std lib checks fine, the transition should be possible. |
Owner changed to @griesemer. Status changed to Started. |
This is done but for the necessary updates to the build scripts (in bradfitz's court now). https://golang.org/cl/12300043 |
This issue was closed by revision 9449c18. Status changed to Fixed. |
gopherbot
added
fixed
Suggested
Issues that may be good for new contributors looking for work to do.
labels
Aug 8, 2013
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
by zhaihj233:
The text was updated successfully, but these errors were encountered: