Fix advanced array merge

fixed issue #4020