Merge pull request #2645 from nspcc-dev/fix-vm-cli-panic

compiler: avoid panic on empty package list
This commit is contained in:
Roman Khimov 2022-08-17 11:37:38 +03:00 committed by GitHub
commit ab577da2b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2185,6 +2185,9 @@ func newCodegen(info *buildInfo, pkg *packages.Package) *codegen {
// codeGen compiles the program to bytecode. // codeGen compiles the program to bytecode.
func codeGen(info *buildInfo) (*nef.File, *DebugInfo, error) { func codeGen(info *buildInfo) (*nef.File, *DebugInfo, error) {
if len(info.program) == 0 {
return nil, nil, errors.New("empty package")
}
pkg := info.program[0] pkg := info.program[0]
c := newCodegen(info, pkg) c := newCodegen(info, pkg)