Monday, May 23, 2011

Re: question about string expression evaluation / bug?

Reply to message «Re: question about string expression evaluation / bug?»,
sent 17:50:18 23 May 2011, Monday
by hsitz:

> So it seems something gets screwed up when the filetype plugin is
> initialized. Strange because (1) no errors are thrown, (2) same code
> works fine on many other systems, and (3) even if something in
> VimOrganizer is screwy I can't imagine proper behavior for vim is to
> have different results for same expression in steps numbered 2 and 5,
> above.
I know about one option that alters the behavior of `==', `!=', `>', `>=', `<',
`<=' when both arguments are strings: it is 'ignorecase'. I don't have
vimOrganizer, but after I read about your problem I guessed that it may be
because vimOrganizer changes value of 'ignorecase' locally. My assumption proved
to be right:
:echo 'DONE' ># ''
1
:echo 'DONE' >? ''
0
This is a reason why I never use `==', `!=', `>', `>=', `<', `<=' for comparing
strings, only `is'/`isnot' (it looks better then `==#' and `!=#') and operators
with either `?' or `#' at the end.

Note that `string is "a"' acts like `type(string)==type("a") && string==#"a"'
unless both left and right operands are lists or dictionaries. When I need to
check for empty string I use `empty()' function.

Original message:
> On May 22, 3:59 pm, Tim Chase <v...@tim.thechases.com> wrote:
> > My first questions would be:
> >
> > 1) what *is* in your vimrc?
> >
> > 2) what's the output of ":version"? This might also be checkable
> > with ":echo 'xxx'>''" to see what it evals as. Depending your
> > version, you might be running with -eval set. According to
> > ":help no-eval-feature", items in an "if" block get ignored if
> > your build doesn't include +eval
> >
> > -tim
>
> Tim -- Thanks for the suggestions (which I answered in previous
> response).
>
> I'm starting to think this is a bug in vim itself. Here's more of the
> background:
>
> The error is happening on an up-to-date ArchLinux system running the
> development branch of the VimOrganizer filetype plugin. (Available
> at: https://github.com/hsitz/VimOrganizer )
>
> I'm author of that plugin and a user complained of problems running
> that I debugged remotely. This problem does not happen on any of my
> Windows installs or on a couple Linux installs I've checked (Ubuntu,
> OpenSuse).
>
> The user is able to replicate the problem this way:
>
> 1. open terminal vim from command line with command 'vim'
> 2. run :echo 'DONE' > '' (properly outputs value of 1)
> 3. quit vim
> 4. open any org file, 'vim anyorgfile.org'
> 5. run :echo 'DONE' > '' (returns invalid output of 0)
>
> So it seems something gets screwed up when the filetype plugin is
> initialized. Strange because (1) no errors are thrown, (2) same code
> works fine on many other systems, and (3) even if something in
> VimOrganizer is screwy I can't imagine proper behavior for vim is to
> have different results for same expression in steps numbered 2 and 5,
> above.
>
> -- Herb
>
>
>
> .

No comments: