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

Uncurried external function with @unwrap polymorphic variant argument does not unwrap in output #5604

Closed
3 of 5 tasks
illusionalsagacity opened this issue Aug 21, 2022 · 6 comments
Milestone

Comments

@illusionalsagacity
Copy link
Contributor

Thank you for filing! Check list:

  • Is it a bug? Usage questions should often be asked in the forum instead.
  • Concise, focused, friendly issue title & description.
  • A minimal, reproducible example.
  • OS and browser versions, if relevant.
  • Is it already fixed in master?

Using 9.1.3 in the example but also does not compile as expected for 10.0.0-rc.1

example here

@cristianoc cristianoc added this to the v11.0 milestone Mar 21, 2023
@cristianoc
Copy link
Collaborator

Not likely to be needed now that we're moving towards uncurried only.

@tatchi
Copy link
Contributor

tatchi commented Jan 9, 2024

Is it expected that with rescript 11 (uncurried mode by default), the following code

@module("react-router-dom")
external useNavigate: unit => @unwrap
[
  | #Str(string)
  | #Int(int)
] => unit = "useNavigate"

let navigate = useNavigate()

navigate(#Str("path"))

Gives

rescript-lang org_try

@tatchi
Copy link
Contributor

tatchi commented Jan 9, 2024

I would have expected the argument to navigate to be unwrapped: navigate("path")

@zth
Copy link
Collaborator

zth commented Jan 9, 2024

Yeah that does look broken. This would be the preferred way to do that in v11:

@unboxed
type stringOrInt = Str(string) | Int(int)

@module("react-router-dom")
external useNavigate: unit => stringOrInt => unit = "useNavigate"

let navigate = useNavigate()

navigate(Str("path"))

@tatchi
Copy link
Contributor

tatchi commented Jan 10, 2024

Oh, we can use unboxed with more than one constructor in rescript 11 😁 Cool, thanks 🤗

@zth
Copy link
Collaborator

zth commented Jan 10, 2024

@tatchi yes! 😄 It's quite powerful, and there's a broad range of things you can put in there and still have it be unboxed: https://rescript-lang.org/docs/manual/latest/variant#what-you-can-unbox

However, this still seems to be a breakage introduced by v11. We should either fix it (unlikely) or mention it clearly in the migration guide. Thanks for reporting!

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

4 participants