Loading ...
Sorry, an error occurred while loading the content.

Re: Questions about "overloading" functions in Vim scripts

Expand Messages
  • Jacky Liu
    ... Indeed! I ve done test on this, just like what you ve pointed out, the problem s with the loop variable of the for-statement, not with the function call. I
    Message 1 of 3 , Jul 27, 2009
    • 0 Attachment
      > Not really possible to be sure given that you haven't shown us any
      > real code, but my wild guess would be that you're iterating over
      > something using a for loop, and the loop variable has the wrong type
      > to hold one of the arguments.  For example:
      >
      >    for item in values({ 'x' : [ 1, 2, 3 ], 'y' : 1 }) | echo item | endfor
      >
      > leads to
      >
      >    [1, 2, 3]
      >    E706: Variable type mismatch for: item
      >
      > because 'item' is a List after the first iteration, but needs to hold
      > a Number on the second iteration.  You can get around this by calling
      > ':unlet item' before the :endfor
      >



      Indeed! I've done test on this, just like what you've pointed out, the
      problem's with the loop variable of the for-statement, not with the
      function call. I wrote pseudocode to better descripe the issue but the
      key information's lost.

      The solution you gave is great, thanks! I don't have to creat 5
      different variables, check the object type and let the right one hold
      it, etc ... (I was thinking about doing so) Actually I would never
      have come up with the idea that a loop variable can be "unlet" before
      the loop ends, but it actually works. Just one more line in the for-
      statement and the function's OK, so great.

      Thanks for the help!
      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.