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

Unbound record field state, seemingly wrong & unexpected? #150

Closed
fxfactorial opened this issue Dec 31, 2017 · 2 comments
Closed

Unbound record field state, seemingly wrong & unexpected? #150

fxfactorial opened this issue Dec 31, 2017 · 2 comments

Comments

@fxfactorial
Copy link

Say our code is:

let profile = ReasonReact.reducerComponent("Profile");

let s = ReasonReact.stringToElement;

let make = (children) => {
  ...profile,
  initialState: fun () => ([]: list(string)),
  reducer: (_, _) => ReasonReact.NoUpdate,
  render: (type f, self) => {
    let []: list(f) = self.state;
    <div> <p> (s("Hello world")) </p> </div>
  }
};

This errors out with:


   8 ┆ reducer: (_, _) => ReasonReact.NoUpdate,
   9 ┆ render: (type f, self) => {
  10 ┆   let []: list(f) = self.state;
  11 ┆   <div> <p> (s("Hello world")) </p> </div>
  12 ┆ }

  Unbound record field state

ninja: build stopped: subcommand failed.
>>>> Finish compiling(exit: 1)

That seems wrong to me.

@jordwalke
Copy link
Member

jordwalke commented Jan 1, 2018

It's interesting that this is happening because of the locally abstract type in the lambda. It looks like locally abstract types are throwing off "type directed record field disambiguation" (which is how OCaml uses inferred types to tell which record field you are actually referring to).
I'm fascinated by why locally abstract types might interfere with (type directed record field disambiguation), but I'm also curious why you are using locally abstract types (I've only seen them be very useful with GADTs, and local module definitions).
Was your intent to make sure render was polymorphic?

@rickyvetter
Copy link
Contributor

This cannot happen with the function component API so I'm closing this out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants