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

[BUG] While skipping eval7() cannot handle dictionaries with keys starting with number correctly

Expand Messages
  • ZyX
    Try the following code: let d={ 0d : 1} if 0 && (d.0d) endif . This code is completely correct if you replace `if 0` with `if 1`, but with `if 0` it throws
    Message 1 of 4 , Sep 29, 2013
    • 0 Attachment
      Try the following code:

      let d={'0d': 1}
      if 0 && (d.0d)
      endif

      . This code is completely correct if you replace `if 0` with `if 1`, but with `if 0` it throws


      Error detected while processing /home/zyx/tmp/vim/subscript-bug.vim:
      line 2:
      E110: Missing ')'
      E15: Invalid expression: 0 && (d.0d)

      . Reason is the following: when `evaluate` argument is set to FALSE in eval7() handle_subscript does not take .0d as dictionary key (because it checks for variable type which is VAR_UNKNOWN if evaluate is FALSE). Thus `.0d` is handled in eval5() like string concatenation and when it tries to evaluate second argument “0d” in eval7() it is handled like number in that big switch(**arg) statement. As a number it can consume only leading zero, which means when eval7() *that is handling top “(d.0d)” expression* sees that in place of getting **arg equal to ')' it gets **arg equal to 'd' and errors out.

      --
      --
      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Bram Moolenaar
      ZyX - ... Right. Overloading . for string concatenation has its disadvantages. For Zimbu I decided to use .. instead. I ll add the bug to the todo list,
      Message 2 of 4 , Sep 29, 2013
      • 0 Attachment
        ZyX -

        > Try the following code:
        >
        > let d={'0d': 1}
        > if 0 && (d.0d)
        > endif
        >
        > . This code is completely correct if you replace `if 0` with `if 1`, but with `if 0` it throws
        >
        >
        > Error detected while processing /home/zyx/tmp/vim/subscript-bug.vim:
        > line 2:
        > E110: Missing ')'
        > E15: Invalid expression: 0 && (d.0d)
        >
        > . Reason is the following: when `evaluate` argument is set to FALSE in eval7() handle_subscript does not take .0d as dictionary key (because it checks for variable type which is VAR_UNKNOWN if evaluate is FALSE). Thus `.0d` is handled in eval5() like string concatenation and when it tries to evaluate second argument “0d” in eval7() it is handled like number in that big switch(**arg) statement. As a number it can consume only leading zero, which means when eval7() *that is handling top “(d.0d)” expression* sees that in place of getting **arg equal to ')' it gets **arg equal to 'd' and errors out.

        Right. Overloading "." for string concatenation has its disadvantages.
        For Zimbu I decided to use ".." instead.

        I'll add the bug to the todo list, hopefully someone can fix it.

        - Bram

        --
        "Never be afraid to tell the world who you are."
        -- Anonymous

        /// Bram Moolenaar -- Bram@... -- 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 vim_dev+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Christian Brabandt
        ... This looks a little bit like the bug that has been fixed with 7.3.841. Nevertheless the fix seems more complicated this time, as I don t know how to only
        Message 3 of 4 , Sep 30, 2013
        • 0 Attachment
          On Sun, September 29, 2013 16:01, ZyX wrote:
          > Try the following code:
          >
          > let d={'0d': 1}
          > if 0 && (d.0d)
          > endif
          >
          > . This code is completely correct if you replace `if 0` with `if 1`, but
          > with `if 0` it throws
          >
          >
          > Error detected while processing /home/zyx/tmp/vim/subscript-bug.vim:
          > line 2:
          > E110: Missing ')'
          > E15: Invalid expression: 0 && (d.0d)
          >
          > . Reason is the following: when `evaluate` argument is set to FALSE in
          > eval7() handle_subscript does not take .0d as dictionary key (because it
          > checks for variable type which is VAR_UNKNOWN if evaluate is FALSE). Thus
          > `.0d` is handled in eval5() like string concatenation and when it tries to
          > evaluate second argument “0d” in eval7() it is handled like number in that
          > big switch(**arg) statement. As a number it can consume only leading zero,
          > which means when eval7() *that is handling top “(d.0d)” expression* sees
          > that in place of getting **arg equal to ')' it gets **arg equal to 'd' and
          > errors out.

          This looks a little bit like the bug that has been fixed with 7.3.841.

          Nevertheless the fix seems more complicated this time, as I don't know
          how to only consume the argument for dictionaries while leaving string
          concatenation alone.

          regards,
          Christian

          --
          --
          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 vim_dev+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Nikolay Pavlov
          ... Thus ... to ... that ... zero, ... and ... This is skipping. We do not care whether it should be treated as concatenation or indexing. In fact all skips
          Message 4 of 4 , Sep 30, 2013
          • 0 Attachment


            On Sep 30, 2013 8:11 PM, "Christian Brabandt" <cblists@...> wrote:
            >
            > On Sun, September 29, 2013 16:01, ZyX wrote:
            > > Try the following code:
            > >
            > >     let d={'0d': 1}
            > >     if 0 && (d.0d)
            > >     endif
            > >
            > > . This code is completely correct if you replace `if 0` with `if 1`, but
            > > with `if 0` it throws
            > >
            > >
            > >     Error detected while processing /home/zyx/tmp/vim/subscript-bug.vim:
            > >     line    2:
            > >     E110: Missing ')'
            > >     E15: Invalid expression: 0 && (d.0d)
            > >
            > > . Reason is the following: when `evaluate` argument is set to FALSE in
            > > eval7() handle_subscript does not take .0d as dictionary key (because it
            > > checks for variable type which is VAR_UNKNOWN if evaluate is FALSE). Thus
            > > `.0d` is handled in eval5() like string concatenation and when it tries to
            > > evaluate second argument “0d” in eval7() it is handled like number in that
            > > big switch(**arg) statement. As a number it can consume only leading zero,
            > > which means when eval7() *that is handling top “(d.0d)” expression* sees
            > > that in place of getting **arg equal to ')' it gets **arg equal to 'd' and
            > > errors out.
            >
            > This looks a little bit like the bug that has been fixed with 7.3.841.
            >
            > Nevertheless the fix seems more complicated this time, as I don't know
            > how to only consume the argument for dictionaries while leaving string
            > concatenation alone.

            This is skipping. We do not care whether it should be treated as concatenation or indexing. In fact all skips take indexing as concatenation always and most of time everything is fine. What we do care is that it should not error out.

            I think that taking dot followed by an identifier character as indexing always (while skipping obviously) (which is something like one-line patch to handle_subscript) should work, but have not constructed a proof for this.

            Allowing any identifier character in a number *while skipping* may also work.

            > regards,
            > Christian
            >
            > --
            > --
            > 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 vim_dev+unsubscribe@....
            > For more options, visit https://groups.google.com/groups/opt_out.

            --
            --
            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 vim_dev+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.