rescript-association / genType

Auto generation of idiomatic bindings between Reason and JavaScript: either vanilla or typed with TypeScript/FlowType.

Home Page:https://rescript-lang.org/docs/gentype/latest/introduction

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Doesn't emit file if a parametric Object type is defined in the file

chrischen opened this issue · comments

If I have some code like this that includes the open Object type, genType stops working for that whole file, even if this code never touches any [@genType] annotation.

module AccountId: {
  type t;
  type errs = [ | `InvalidAccountId];
  type context('a) = {.. accountIdExists: bool} as 'a; // If I get rid of this it works
} = {
  type t = string;
  type errs = [ | `InvalidAccountId];
  type context('a) = {.. accountIdExists: bool} as 'a;
};

[@genType]
let test = (): string => "this just doesn't get emitted";

Compiler compiles my code but this message is also shown

Fatal error: exception File "src/TypeVars.re", line 11, characters 16-22: Assertion failed

Changing the object type to a closed one and getting rid of the param works.

type context = {. accountIdExists: bool};

This still doesn't work.
type context('a) = {. accountIdExists: bool};

However, if I remove the parametric object from the interface and leave it in the implementation it works.

Thanks. Probably the recent compiler change to the object representation exposes a code path that was not encountered before.

@chrischen here's a first fix for the issue you have observed:
#537

Al least it prevents the existence of that declaration from blocking the rest of the file.