Yasuhiro Matsumoto wrote:

> Can you explain this behavior in docs for users?

Yes.

> -------------------------
> function! s:type(x)
>   return a:x
> endfunction
> 
> let s:type = function('type')
> " => E705
> -------------------------

I do not get this error.

> function! Type(x)
>   return a:x
> endfunction
> 
> let Type = function('type')
> " => E705
> -------------------------

Correct, Type was already defined, you can't define a variable with the
same name.

> 
> function! s:type(x)
>   return a:x
> endfunction
> 
> let s:type = 0
> 
> echo s:type('x')
> " => 'x'
> -------------------------

That looks like a bug, should not allow assignment to s:type.

> let s:type = function('type')
> 
> function! s:type(x)
>   return a:x
> endfunction
> 
> echo s:type('x')
> " => 1
> -------------------------

Same bug the other way around.

> let s:type = function('type')
> 
> function! s:type(x)
>   return a:x
> endfunction
> 
> let s:type = function('type')
> 
> echo s:type('x')
> " => 1

Looks like the same thing.

So the bug appears to be that it's possible to have a variable and a
function with the same name when they are script-local.

-- 
WOMAN:   I didn't know we had a king. I thought we were an autonomous
         collective.
DENNIS:  You're fooling yourself.  We're living in a dictatorship.  A
         self-perpetuating autocracy in which the working classes--
WOMAN:   Oh there you go, bringing class into it again.
DENNIS:  That's what it's all about if only people would--
                                  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui