config icon indicating copy to clipboard operation
config copied to clipboard

Array concatenation missing checks

Open carueda opened this issue 4 years ago • 1 comments

I'm reviewing HOCON's array-and-object-concatenation and wondering what the expected parse result should be for "wrong" inputs like the following:

  1. list = [0, 1] | [2,3]
  2. list = [0] bar baz [1,2,3]
  3. list = [0] abc [bar, baz] ||| xyz [1,2,3]

Per the rendering program below, the non-array tokens in between the arrays seem to just be silently ignored:

  1. list = [0, 1] | [2,3]:

     {
         "list" : [
             0,
             1,
             2,
             3
         ]
     }
    
  2. list = [0] bar baz [1,2,3]:

     {
         "list" : [
             0,
             1,
             2,
             3
         ]
     }
    
  3. list = [0] abc [bar, baz] ||| xyz [1,2,3]:

     {
         "list" : [
             0,
             "bar",
             "baz",
             1,
             2,
             3
         ]
     }
    

Shouldn't an exception be thrown in these cases? Thanks.


Config c = ConfigFactory.parseString(input).resolve();
ConfigRenderOptions options = ConfigRenderOptions.defaults().setOriginComments(false);
System.out.println(c.root().render(options));

carueda avatar May 06 '20 21:05 carueda

Without carefully re-reading the spec and code, my first impression is that I agree with you, I would expect an exception in these cases.

havocp avatar May 06 '20 21:05 havocp