Closed
Description
The inliner replaces parameters by their arguments when possible. If the argument is a constant, then certain expressions that were statically valid (but would panic if evaluated) before are now statically invalid. For example, attempting to slice an empty string:
func _() {
const s = ""
f(s)
}
func (s string) { _ = s[:1] } // error: cannot slice empty string
or negating minint:
func _() {
const x = -0x80000000
f(x)
}
func f(x int32) { var _ int32 = -x } // error: - -0x80000000 overflows int32
In general I suspect such errors cannot be detected without executing the type checker on the result, which is not something that can be done by the inliner itself. Sigh.