Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c1a695c1
Commit
c1a695c1
authored
Feb 03, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gc, ld: package name main no longer reserved
R=ken2 CC=golang-dev
https://golang.org/cl/4128054
parent
eff19528
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
10 deletions
+9
-10
src/cmd/gc/go.y
src/cmd/gc/go.y
+0
-8
src/cmd/gc/lex.c
src/cmd/gc/lex.c
+9
-0
src/cmd/ld/go.c
src/cmd/ld/go.c
+0
-2
No files found.
src/cmd/gc/go.y
View file @
c1a695c1
...
...
@@ -242,14 +242,6 @@ import_package:
if(safemode && !curio.importsafe)
yyerror("cannot import unsafe package %Z", importpkg->path);
// NOTE(rsc): This is no longer a technical restriction:
// the 6g tool chain would work just fine without giving
// special meaning to a package being named main.
// Other implementations might need the restriction
// (gccgo does), so it stays in the language and the compiler.
if(strcmp($2->name, "main") == 0)
yyerror("cannot import package main");
}
import_safety:
...
...
src/cmd/gc/lex.c
View file @
c1a695c1
...
...
@@ -423,6 +423,15 @@ importfile(Val *f, int line)
errorexit
();
}
// The package name main is no longer reserved,
// but we reserve the import path "main" to identify
// the main package, just as we reserve the import
// path "math" to identify the standard math package.
if
(
strcmp
(
f
->
u
.
sval
->
s
,
"main"
)
==
0
)
{
yyerror
(
"cannot import
\"
main
\"
"
);
errorexit
();
}
if
(
strcmp
(
f
->
u
.
sval
->
s
,
"unsafe"
)
==
0
)
{
if
(
safemode
)
{
yyerror
(
"cannot import package unsafe"
);
...
...
src/cmd/ld/go.c
View file @
c1a695c1
...
...
@@ -148,8 +148,6 @@ ldpkg(Biobuf *f, char *pkg, int64 len, char *filename, int whence)
}
if
(
strcmp
(
pkg
,
"main"
)
==
0
&&
strcmp
(
name
,
"main"
)
!=
0
)
fprint
(
2
,
"%s: %s: not package main (package %s)
\n
"
,
argv0
,
filename
,
name
);
else
if
(
strcmp
(
pkg
,
"main"
)
!=
0
&&
strcmp
(
name
,
"main"
)
==
0
)
fprint
(
2
,
"%s: %s: importing %s, found package main"
,
argv0
,
filename
,
pkg
);
loadpkgdata
(
filename
,
pkg
,
p0
,
p1
-
p0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment