Try to interpret simple function calls in init() functions

This is useful for example for globals like these:

    import "errors"

    var MyError = errors.New("mymodule: something went wrong!")
This commit is contained in:
Ayke van Laethem
2018-08-30 05:52:42 +02:00
parent 15f62b29cf
commit 16cdffc367
2 changed files with 83 additions and 3 deletions
+3
View File
@@ -1036,6 +1036,9 @@ func (c *Compiler) parseFunc(frame *Frame) error {
return err
}
}
if frame.fn.fn.Name() == "init" && len(block.Instrs) == 0 {
c.builder.CreateRetVoid()
}
}
// Resolve phi nodes