compiler: fix odd bounds check failure with impossible typeassert

This commit is contained in:
Ayke van Laethem
2018-10-20 17:21:47 +02:00
parent 77d6d6c417
commit 3f05490846
+2 -2
View File
@@ -2049,8 +2049,8 @@ func (c *Compiler) emitBoundsCheck(frame *Frame, arrayLen, index llvm.Value) {
}
// Optimize away trivial cases.
// LLVM would do this anyway with interprocedural optimizations, but it
// helps to see cases where bounds checking would really help.
if index.IsConstant() && arrayLen.IsConstant() {
// helps to see cases where bounds check elimination would really help.
if index.IsConstant() && arrayLen.IsConstant() && !arrayLen.IsUndef() {
index := index.SExtValue()
arrayLen := arrayLen.SExtValue()
if index >= 0 && index < arrayLen {