Closed mrmurphy closed 4 years ago
Experiencing the same issue 🙁
I'm not able to reproduce this. Can you provide your bsconfig?
Repro: https://github.com/baransu/ppx_decco-variant-error-repo Code:
[@decco]
type status =
| Active
| Inactive(float);
[@decco]
type user = {
name: string,
status,
};
Thanks for the repo. It looks like it's caused by opening Belt
. I'll take a closer look later
TIL OCaml's array indexing syntax is just syntactic sugar for Array.get
. In other words, var[0]
is equivalent to Array.get(var, 0)
This is the source of your error: OCaml's native Array.get
returns the actual value directly (throwing an error if the index is out of bounds), while Belt.Array.get
returns an option. When you open Belt, it changes the behavior of var[0]
.
See: https://stackoverflow.com/a/46394530/1953740
I guess I can fix it by avoiding that array syntax and just using Belt.Array directly.
Deployed a fix in version v0.2.2 for BS 6 and v0.1.1 for BS 5.
Thank you a lot!
Very strange, but when I drop this into any file in my project:
I get the following error message:
Decco version 0.1.0, bs-platform version 5.2.1.
Thank you!