mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 13:33:39 +00:00
loader: don't panic when main package is not named 'main'
This can in fact happen in practice, so return an actual error message instead.
This commit is contained in:
+6
-2
@@ -418,8 +418,12 @@ func (p *Package) Check() error {
|
||||
packageName := p.ImportPath
|
||||
if p == p.program.MainPkg() {
|
||||
if p.Name != "main" {
|
||||
// Sanity check. Should not ever trigger.
|
||||
panic("expected main package to have name 'main'")
|
||||
return Errors{p, []error{
|
||||
scanner.Error{
|
||||
Pos: p.program.fset.Position(p.Files[0].Name.Pos()),
|
||||
Msg: fmt.Sprintf("expected main package to have name \"main\", not %#v", p.Name),
|
||||
},
|
||||
}}
|
||||
}
|
||||
packageName = "main"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user