What makes the difference ? | if and dict

1 view
Skip to first unread message

Marc Weber

unread,
Dec 2, 2008, 10:02:55 PM12/2/08
to vim...@googlegroups.com
if (1 >= 1) | let d = 1 | else | let d = "soo" | endif
if (1 >= 1) | let d = 1 | else | let d = {'evalLazyClosedArgs': 1} | endif

You can execute the first line in cmd line.
The second fails. Why ?

Marc Weber

John Beckett

unread,
Dec 2, 2008, 11:42:44 PM12/2/08
to vim...@googlegroups.com
Marc Weber wrote:
> if (1 >= 1) | let d = 1 | else | let d = "soo" | endif
> if (1 >= 1) | let d = 1 | else | let d = {'evalLazyClosedArgs': 1} | endif

The problem is simply that after you have execute the first line, the global
variable d contains a number (1). You're not able to change the type of a variable
from number to dictionary.

If you ':unlet d' before the second line, it works (:help E706).

John

John Beckett

unread,
Dec 2, 2008, 11:49:03 PM12/2/08
to vim...@googlegroups.com
John Beckett wrote:
> The problem is simply that after you have execute the first
> line, the global variable d contains a number (1). You're not
> able to change the type of a variable from number to dictionary.

On actually reading this, I see it quite misses the point.

Strangely, the first time I executed line 1 followed by line 2, I got your error. On
retrying, I do not. I have to go elsewhere ... may think later.

John

Matt Wozniski

unread,
Dec 3, 2008, 12:03:28 AM12/3/08
to vim...@googlegroups.com

Both seem to work for me... larger test case?

~Matt

Marc Weber

unread,
Dec 3, 2008, 12:38:33 AM12/3/08
to vim...@googlegroups.com

No. I must have had d defined as int or such then. I've had a problem
with this using exec and d should have been a local not yet defined var
there. I have to go to bed now. I just didn't see any error message.

Thanks
Marc Weber

John Beckett

unread,
Dec 3, 2008, 2:10:50 AM12/3/08
to vim...@googlegroups.com
Marc Weber wrote:
> No. I must have had d defined as int or such then.

I've worked out where I went wrong. I was confused by the the 'evalLazyClosedArgs'
text (and wondered if the actual text was somehow relevant). I did a ":let d =
{'x':1}" before trying your command (putting a dictionary into d). But your command
tries to put the number 1 into d, which triggered the error.

John

Tony Mechelynck

unread,
Dec 3, 2008, 3:49:16 PM12/3/08
to vim...@googlegroups.com

Works for me. What error do you get?


Best regards,
Tony.
--
This will be a memorable month -- no matter how hard you try to forget
it.

Reply all
Reply to author
Forward
0 new messages