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

Arity check %raw #6213

Closed
Tracked by #6211
cristianoc opened this issue Apr 26, 2023 · 2 comments
Closed
Tracked by #6211

Arity check %raw #6213

cristianoc opened this issue Apr 26, 2023 · 2 comments
Milestone

Comments

@cristianoc
Copy link
Collaborator

Check that the JS code is a function of the arity specified by the type annotation.

E.g.: this is fine as the arity of the type matches the arity of JS.

let canUseCanvas: unit => bool = %raw(`
  function canUseCanvas() {
    return !!document.createElement('canvas').getContext;
  }
`)
@cristianoc cristianoc added this to the v12 milestone Apr 26, 2023
@cristianoc
Copy link
Collaborator Author

cristianoc added a commit that referenced this issue May 13, 2023
Only print to stderr for now?

See #6213
cristianoc added a commit that referenced this issue May 23, 2023
Only print to stderr for now?

See #6213
cristianoc added a commit that referenced this issue May 23, 2023
* Begin exposing %raw arity

Only print to stderr for now?

See #6213

* Use %ffi attribute and handle arity zero

Move to using `%ffi` extension to avoid breaking changes, and begin checking arity zero.

For a JS function of arity 0, check that the ReScript type is `unit => _`.

* Check all arities and make error message gpt3.5-proof.

Extend arity check to all arities.

Iterate on the error message so gpt3.5 can figure out a correct fix when given the error message with no context.

* One more example.

* cleanup

* format

* comment

* Update CHANGELOG.md
@cristianoc
Copy link
Collaborator Author

Done. This is now called %ffi.

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

1 participant