2016-10-26 19:27 GMT+03:00 LCD 47 <[email protected]>:
>     Today I stumbled upon this article about JSON:
>
>         http://seriot.ch/parsing_json.php
>
>     The article links to a set of tests:
>
>         https://github.com/nst/JSONTestSuite
>
>     A quick run of the "y" and "n" tests against Vim's json_decode()
> finds a few problems.  Not particularly ground-breaking, but perhaps
> worth fixing:
>
> * These should be accepted, but aren't:
>
>         json_decode('{"a":"b","a":"c"}')    " E685

According to the spec, behaviour is implementation-defined in this
case. Error is acceptable and if tests state otherwise they are wrong.
Specifically *E685* error is not, it always indicates a bug.

Relevant quote from https://tools.ietf.org/html/rfc7159#section-4:

> When the names within an object are not
> unique, the behavior of software that receives such an object is
> unpredictable.  Many implementations report the last name/value pair
> only.  Other implementations report an error or fail to parse the
> object, and some implementations report all of the name/value pairs,
> including duplicates.


>         json_decode('{"a":"b","a":"b"}')    " E685

Same.

>         json_decode('{"":0}')               " E474

Not too much time passed since Vim started to allow empty strings.
Though I agree that this is a bug now, this had a reason not to work.
Neovim uses special dictionaries in this case, but I could not
consider them easy to use.

>
> * These should be rejected, but aren't:
>
>         json_decode('["",]')                " ['']
>         json_decode('[1,]')                 " [1]
>         json_decode('{1:1}')                " {'1': 1}
>         json_decode('{"id":0,}')            " {'id': 0}
>         json_decode('["\uD800\u"]')         " ['<d800>']
>         json_decode('["\uD800\u1"]')        " ['<d800><01>']
>         json_decode('["\uD800\u1x"]')       " ['<d800><01>x']
>         json_decode('["\x00"]')             " ['x00']
>         json_decode('["\a"]')               " ['a']
>         json_decode('[True]')               " [v:true]

AFAIR Bram explicitly said that he is going to accept some
non-standard syntax when I raised the similar question.

>
> * There is even a segfault:
>
>         json_decode(repeat('[', 100000))    " segfault

One of the reasons I did not import Vim implementation to Neovim: it
is recursive.

>
>     There are others, the above are just the main ones.  Also, for the
> "n" tests I was just checking that json_decode() rises an exception, not
> that the exception rised actually makes sense.

Vim errors at 8.0.42 still suck, I did much better when writing
json_decode for Neovim.

>
>     /lcd
>
> --
> --
> 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.

-- 
-- 
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