rescript-lang / rescript-compiler

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

8.0.0-dev.1: bs.inline for floats #4426

Closed cknitt closed 4 years ago

cknitt commented 4 years ago

@bobzhang In BS7, the following worked:

[@bs.inline]
let x = 42.;

In BS8, it does not work anymore, I get the error message

  invalid payload in bs.inline

Revisiting the original issue, I found that you were saying "currently support bs.inline for boolean/int/string" (https://github.com/BuckleScript/bucklescript/issues/3472#issuecomment-480799386).

So it seems this was only working for floats "by coincidence" in BS7. Still, would be nice to have it in BS8.

bobzhang commented 4 years ago

It was not supported but the error message did not report it, so it's fixed. Do you have use case for that?

On Fri, May 29, 2020 at 1:33 PM Christoph Knittel notifications@github.com wrote:

@bobzhang https://github.com/bobzhang In BS7, the following worked:

[@bs.inline]let x = 42.;

In BS 8, it does not work anymore, I get the error message

invalid payload in bs.inline

Revisiting the original issue, I found that you were saying "currently support bs.inline for boolean/int/string" (#3472 (comment) https://github.com/BuckleScript/bucklescript/issues/3472#issuecomment-480799386 ).

So it seems this was only working "by coincidence" in BS7. Still, would be nice to have it in BS8.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BuckleScript/bucklescript/issues/4426, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFWMK43GFI32AQD6EZIRS3RT5CMFANCNFSM4NNXLPOA .

-- Regards -- Hongbo Zhang

cknitt commented 4 years ago

I think inlined float constants are just as useful as inlined int constants.

One use case that immediately comes to mind are layout constants (widths, heights, margins, opacity values, ...) for bs-css or reason-react-native code.

I would appreciate it if we could get inlined float constants officially supported in BS8.