Skip to content

Shadowing of js constructors in generated output #3214

Closed

Description

@alex35mil
/* Promise.re */
type t(+'a) = Js.Promise.t('a);

[@bs.val] [@bs.scope "Promise"] external resolve: 'a => t('a) = "resolve";

[@bs.send]
external andThen: (t('a), [@bs.uncurry] ('a => t('b))) => t('a) = "then";

let wait = (x, fn) => x->andThen(x => x->fn->resolve)->ignore;

/* App.re */
1->Promise.resolve()->Promise.wait();

App.re compiles to something like:

import * as Promise from "...";

Promise.wait(Promise.resolve(1));

And Promise.resolve is undefined at runtime b/c it supposed to be a property on js Promise object but it shadowed by imported Promise module.

Activity

  1. added a commit that references this issue on Dec 21, 2018
    2fbd7de
  2. added a commit that references this issue on Dec 21, 2018
    6d65617
  3. added theissue type on Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions