Christian Ebert wrote:

> The following test script gives an error in vim6.2 when it is
> sourced:
> 
> function TestFor()
>   if exists(":for")
>     " v:version >= 700
>     let l:test = []
>     for word in ["hello", "world"]
>       call add(l:test, word)
>     endfor
>     return join(l:test)
>   else
>     return "hello world"
>   endif
> endfunction
> 
> I wanted to use the exists clause to fork a script according to
> the current vim version, and this works in other cases.
> 
> The problem is the for-loop, it doesn't choke on something like
> add() which is also new in vim7.
> 
> Am I doing something wrong, or is this a bug?

I can't change 6.x versions to fix this.  The problem is that the
"endfor" is seen as "endfunction".  Only the "endf" is checked for.

You can work around it by putting the "endfor" after another command:

      call add(l:test, word) | endfor

-- 
hundred-and-one symptoms of being an internet addict:
36. You miss more than five meals a week downloading the latest games from
    Apogee.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

Reply via email to