Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

atdgen can put types in the wrong order #70

Open
dwwoelfel opened this issue Apr 21, 2018 · 3 comments
Open

atdgen can put types in the wrong order #70

dwwoelfel opened this issue Apr 21, 2018 · 3 comments
Labels
bug help wanted target:ocaml Issues related to the OCaml backend (atdgen)

Comments

@dwwoelfel
Copy link

I'm running into an issue where my atd definition will succeed in generating an ml file of types (atdgen -t), but the file won't compile.

I managed to reduce it to the following. If I remove any of the definitions, then compiling the generated test_t.ml file succeeds.

type sku = {
  product: product;
}

type product = {
  sku: sku;
}

type plan = {
  product: product;
}

type customer = {
  plan: plan;
  customer: customer;
}

type charge = {
  order: order;
}

type order = {
  charge: charge;
  sku: sku;
}

The generated file (atdgen -t test.atd):

(* Auto-generated from "test.atd" *)

type plan = { product: product }

type customer = { plan: plan; customer: customer }

type product = { sku: sku }

and sku = { product: product }

type charge = { order: order }

and order = { charge: charge; sku: sku }
$ ocamlc src/test_t.ml
File "src/test_t.ml", line 4, characters 23-30:
Error: Unbound type constructor product
@mjambon
Copy link
Collaborator

mjambon commented Apr 21, 2018

Thanks for the repro case.

@mjambon mjambon added the bug label Apr 21, 2018
@rgrinberg
Copy link
Collaborator

@dwwoelfel as a workaround, could you check if the -rec flag helps?

@dwwoelfel
Copy link
Author

Thanks @rgrinberg! That solves the problem for me for now :)

@mjambon mjambon added the target:ocaml Issues related to the OCaml backend (atdgen) label Feb 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help wanted target:ocaml Issues related to the OCaml backend (atdgen)
Projects
None yet
Development

No branches or pull requests

3 participants