compiler: fix odd bounds check failure with impossible typeassert

Этот коммит содержится в:
Ayke van Laethem 2018-10-20 17:21:47 +02:00
родитель 77d6d6c417
коммит 3f05490846
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

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

@ -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 {