reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.12k stars 428 forks source link

Children spread + List.cons gets refmted into semantically different code #2591

Closed jchavarri closed 4 years ago

jchavarri commented 4 years ago

Input:

<head>
  ...{[title, ...other_elements]}
</head>

which would produce something like this (in .ml syntax):

let _ = ((head ~children:(title :: other_elements) ())[@JSX ])

gets transformed into:

<head>
  title
  other_elements
</head>

Which is a very different thing:

let _ = ((head ~children:[title; other_elements] ())[@JSX ])
jfrolich commented 4 years ago

Perhaps this syntax would be nice to have: <tr>...{[<b/>,...doc]}</tr> into <a> <b /> ...doc </a>

jordwalke commented 4 years ago

Looked into this. I found out where it's happening. formatChildren function needs to bail out on any list cons :: which is not ending in a nil termination [].