fix bugs when dynamic array is passed as VAR argument