Permalink
Browse files

Fix a bug with embedded structs in packages as ordinary fields. Add t…

…est case.
  • Loading branch information...
1 parent a34a1ba commit e4145d399a6da4a38aee182fc29608d7bea42503 @nsf committed Jul 26, 2012
Showing with 40 additions and 7 deletions.
  1. +1 −0 _testing/DESC
  2. 0 _testing/test.0036/cursor.67
  3. +19 −0 _testing/test.0036/out.expected
  4. +8 −0 _testing/test.0036/test.go
  5. +6 −6 gocode.go
  6. +6 −1 package.go
View
@@ -33,3 +33,4 @@ test.0032 - import all packages (tests package parser)
test.0033 - varargs type as a slice type in different contexts
test.0034 - interface with methods imported from another package
test.0035 - built-in "error" interface
+test.0036 - embedded struct in a package as an ordinary field
No changes.
@@ -0,0 +1,19 @@
+Found 18 candidates:
+ func Close() error
+ func DWARF() (*dwarf.Data, error)
+ func ImportedLibraries() ([]string, error)
+ func ImportedSymbols() ([]elf.ImportedSymbol, error)
+ func Section(name string) *elf.Section
+ func SectionByType(typ elf.SectionType) *elf.Section
+ func Symbols() ([]elf.Symbol, error)
+ var ABIVersion uint8
+ var ByteOrder binary.ByteOrder
+ var Class elf.Class
+ var Data elf.Data
+ var FileHeader elf.FileHeader
+ var Machine elf.Machine
+ var OSABI elf.OSABI
+ var Progs []*elf.Prog
+ var Sections []*elf.Section
+ var Type elf.Type
+ var Version elf.Version
@@ -0,0 +1,8 @@
+package main
+
+import "debug/elf"
+
+func main() {
+ var f elf.File
+ f.
+}
View
@@ -26,18 +26,18 @@ func get_socket_filename() string {
func show_usage() {
fmt.Fprintf(os.Stderr,
"Usage: %s [-s] [-f=<format>] [-in=<path>] [-sock=<type>] [-addr=<addr>]\n"+
- " <command> [<args>]\n\n",
+ " <command> [<args>]\n\n",
os.Args[0])
fmt.Fprintf(os.Stderr,
"Flags:\n")
flag.PrintDefaults()
fmt.Fprintf(os.Stderr,
"\nCommands:\n"+
- " autocomplete [<path>] <offset> main autocompletion command\n"+
- " close close the gocode daemon\n"+
- " status gocode daemon status report\n"+
- " drop-cache drop gocode daemon's cache\n"+
- " set [<name> [<value>]] list or set config options\n")
+ " autocomplete [<path>] <offset> main autocompletion command\n"+
+ " close close the gocode daemon\n"+
+ " status gocode daemon status report\n"+
+ " drop-cache drop gocode daemon's cache\n"+
+ " set [<name> [<value>]] list or set config options\n")
}
func main() {
View
@@ -369,8 +369,13 @@ func (p *gc_parser) parse_field() *ast.Field {
tag = p.expect(scanner.String)
}
+ var names []*ast.Ident
+ if name != "?" {
+ names = []*ast.Ident{ast.NewIdent(name)}
+ }
+
return &ast.Field{
- Names: []*ast.Ident{ast.NewIdent(name)},
+ Names: names,
Type: typ,
Tag: &ast.BasicLit{Kind: token.STRING, Value: tag},
}

0 comments on commit e4145d3

Please sign in to comment.