rescript-lang / rescript-compiler

The compiler for ReScript.
https://rescript-lang.org
Other
6.74k stars 448 forks source link

Dot notation uncurry does not get applied correctly in Pstr_eval #4323

Closed rickyvetter closed 4 years ago

rickyvetter commented 4 years ago

We've noticed while looking at https://github.com/reasonml/reason-react/pull/529 that uncurried functions don't seem to compile as expected when eval'd at a module level. This code will error in a way that implies that the bs annotation isn't read. I believe that it's related to uncurried(. a => a); desugaring to @@bs instead of @bs in this instance - so maybe this issue should be directed to the Reason repo. I'm actually not sure.

[@bs.val]
external retUncurried: unit => (. (unit => unit)) => unit = "retUncurried";
let uncurried = retUncurried();
uncurried(. a => a);
external retUncurried :
  unit -> (((unit -> unit) -> unit)[@bs ]) = "retUncurried"[@@bs.val ]
let uncurried = retUncurried ()
let _ = uncurried (fun a  -> a)[@@bs ]
This is an uncurried BuckleScript function. It must be applied with a dot.

Like this: foo(. a, b)
Not like this: foo(a, b)
anmonteiro commented 4 years ago

I think this is fixed in https://github.com/facebook/reason/pull/2566

corresponding issue in the reason repo: https://github.com/facebook/reason/issues/2565

rickyvetter commented 4 years ago

Yup! Thanks for the fix :)