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

mel.as inside polyvariants should warn about not using mel.string #877

Closed
davesnx opened this issue Nov 7, 2023 · 3 comments
Closed

mel.as inside polyvariants should warn about not using mel.string #877

davesnx opened this issue Nov 7, 2023 · 3 comments

Comments

@davesnx
Copy link
Member

davesnx commented Nov 7, 2023

Combine mel.as in more places is indeed interesting, since would allow to idiomatically bind to JS with 0 cost.

An example of lowercasing them (a silly example)

external foo: (~arg: [ | [@mel.as "lola"] `Lola | [@mel.as "flores"] `Flores]) => unit = "asdf";

let _ = foo(~arg=`Lola);
@davesnx
Copy link
Member Author

davesnx commented Nov 7, 2023

Silly me, adding [@mel.string] works with this case.

external foo:
  (
    ~arg: [@mel.string] [ | [@mel.as "lola"] `Lola | [@mel.as "flores"] `Flores]
  ) =>
  unit =
  "asdf";

let _ = foo(~arg=`Lola);

My first code should have alerted me to add mel.string.

@davesnx davesnx changed the title mel.as inside polyvariants mel.as inside polyvariants should warn about not using mel.string Nov 7, 2023
@jchavarri
Copy link
Member

I think it should work without mel.string too (playground).

The expected behavior should be to warn when using mel.string with poly variants. It warns when mel.as is not used, but for some reason it doesn't warn when both mel.string and mel.as are used. I opened #778 to track the inconsistencies in alerts like that (see companion tests in the issue).

@anmonteiro
Copy link
Member

My first code should have alerted me to add mel.string.

It works without @mel.string since #722

$ melc -ppx melppx  x.ml
// Generated by Melange
'use strict';


asdf("lola");

/*  Not a pure module */

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