Skip to content

Commit f14c4fa

Browse files
authored
Merge pull request #296 from darren/clean_symbol
gen symbol name use index to avoid illegal symobl name
2 parents 8844d76 + e7b2a5e commit f14c4fa

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

bind/symbols.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ type symtab struct {
385385
syms map[string]*symbol
386386
imports map[string]string // key is full path, value is unique name
387387
importNames map[string]string // package name to path map -- for detecting name conflicts
388-
uniqName byte // char for making package name unique
388+
uniqName int // index for making package name unique
389389
parent *symtab
390390
}
391391

@@ -435,13 +435,11 @@ func (sym *symtab) addImport(pkg *types.Package) string {
435435
}
436436
ep, exists = sym.importNames[nm]
437437
if exists && ep != p {
438-
if sym.uniqName == 0 {
439-
sym.uniqName = 'a'
440-
} else {
438+
if exists && ep != p {
441439
sym.uniqName++
440+
unm = fmt.Sprintf("s%d_%s", sym.uniqName, nm)
441+
fmt.Printf("import conflict: existing: %s new: %s alias: %s\n", ep, p, unm)
442442
}
443-
unm = string([]byte{sym.uniqName}) + nm
444-
fmt.Printf("import conflict: existing: %s new: %s alias: %s\n", ep, p, unm)
445443
}
446444
sym.importNames[unm] = p
447445
sym.imports[p] = unm

0 commit comments

Comments
 (0)