Recursive type definition breaks @unboxed
This works:
type x = {id: string}
@unboxed type xOrArray = X(x) | Array(array<x>)
but this doesn't:
type rec x = {id: string}
@unboxed and xOrArray = X(x) | Array(array<x>)
It gives the error
This untagged variant definition is invalid: Case X has a payload that is not of one of the recognized shapes (object, array, etc). Then it must be the only case with payloads.
(I came across the problem when creating type definitions for JSON schema.)
@cknitt not related to this, but I have JSON schema type publicly available https://github.com/DZakh/rescript-json-schema/blob/main/src/JSONSchema7.res
Haven't started updating it to use @unboxed variables though. It'll be much more convenient to use when it happens.
@DZakh Thanks for the hint! I already took inspiration from there 😄, but I needed JSON schema v4 and wanted to use unboxed variants.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is still open.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This was fixed by https://github.com/rescript-lang/rescript/pull/7320