]> Cypherpunks repositories - gostls13.git/commitdiff
special case check for this situation
authorRuss Cox <rsc@golang.org>
Fri, 3 Apr 2009 04:46:19 +0000 (21:46 -0700)
committerRuss Cox <rsc@golang.org>
Fri, 3 Apr 2009 04:46:19 +0000 (21:46 -0700)
; cat >http.go
package main
import "http"  // intended the library, not this file
^D
; 6g http.go
; 6g http.go
http.go:4: export/package mismatch: init
;

new error:

http.6:7 http.go:3: cannot import package main

R=ken
OCL=27053
CL=27053

src/cmd/gc/go.y

index d6155f9f243848726e2134b72dc65e26e0d49ead..9cd7de11627188e81c9757ab6a10598aa17191db 100644 (file)
@@ -173,6 +173,9 @@ import_package:
        {
                pkgimportname = $2;
 
+               if(strcmp($2->name, "main") == 0)
+                       yyerror("cannot import package main");
+
                // if we are not remapping the package name
                // then the imported package name is LPACK
                if(pkgmyname == S)