Skip to content

Commit 679e6b3

Browse files
committed
support package name with backslashes
1 parent e66c818 commit 679e6b3

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

cmd/cell/build/build.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"log"
77
"os"
88
"os/exec"
9+
"path/filepath"
910
"strings"
1011

1112
"github.com/cell-labs/cell-script/compiler/compiler"
@@ -158,7 +159,8 @@ func compilePackage(c *compiler.Compiler, path, name string, options *option.Opt
158159
if packagePath == "os" {
159160
continue
160161
}
161-
if c.IsPackageImported(packagePath) {
162+
packageName := filepath.Base(packagePath)
163+
if c.IsPackageImported(packageName) {
162164
continue
163165
}
164166

compiler/compiler/compiler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package compiler
22

33
import (
44
"fmt"
5+
"path/filepath"
56
"runtime"
67
"runtime/debug"
78

@@ -157,7 +158,7 @@ func (c *Compiler) Compile(root parser.PackageNode) (err error) {
157158
}
158159
}()
159160

160-
c.currentPackageName = root.Name
161+
c.currentPackageName = filepath.Base(root.Name)
161162
if !c.IsPackageImported(c.currentPackageName) {
162163
c.currentPackage = NewPkg(c.currentPackageName)
163164
c.packages[c.currentPackageName] = c.currentPackage

compiler/parser/parser.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package parser
33
import (
44
"fmt"
55
"log"
6+
"path/filepath"
67
"strconv"
78

89
"errors"
@@ -519,7 +520,8 @@ func (p *parser) parseOneWithOptions(withAheadParse, withArithAhead, withIdentif
519520

520521
if current.Val == "import" {
521522
imp := p.parseImport()
522-
for _, n := range imp.PackagePaths {
523+
for _, path := range imp.PackagePaths {
524+
n := filepath.Base(path)
523525
p.packages[n] = struct{}{}
524526
}
525527
return imp

0 commit comments

Comments
 (0)