compiler: allow multiple basic blocks in package initializers

I don't know why they sometimes have them, but apparently some packages
do. Don't panic in that case, the interpreter will stop anyway on the
first branch.
Этот коммит содержится в:
Ayke van Laethem 2018-11-03 20:22:00 +01:00
родитель a531caa2e9
коммит e930a1ead5
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -289,9 +289,6 @@ func (c *Compiler) Compile(mainPath string) error {
for _, frame := range frames {
if frame.fn.Synthetic == "package initializer" {
c.initFuncs = append(c.initFuncs, frame.fn.LLVMFn)
if len(frame.fn.Blocks) != 1 {
panic("unexpected number of basic blocks in package initializer")
}
// Try to interpret as much as possible of the init() function.
// Whenever it hits an instruction that it doesn't understand, it
// bails out and leaves the rest to the compiler (so initialization