2

This compiles in ReasonML:

let testFn = who => Js.(log("Hello " ++ who ++ "!"));

but not in ReScript:

FAILED: src/test.ast

  Syntax error!
  /xxx/src/test.res:1:25-27

  1 │ let testFn = who => Js.(log("Hello " ++ who ++ "!"));
  2 │

  I'm not sure what to parse here when looking at "(".


  Syntax error!
  /xxx/src/test.res:1:25-27

  1 │ let testFn = who => Js.(log("Hello " ++ who ++ "!"));
  2 │

  consecutive statements on a line must be separated by ';' or a newline

I didn't find any mention of removal in official docs. Did I miss it? Has syntax changed, or was it removed and not mentioned in docs?

glennsl
  • 28,186
  • 12
  • 57
  • 75
menfon
  • 1,587
  • 1
  • 11
  • 28
  • 1
    ReScript syntax doesn't support it at the moment: https://github.com/rescript-lang/syntax/issues/2 . This question would be better to ask in the ReScript forum as the syntax is still evolving and the situation may change quickly. – Yawar Jan 27 '21 at 04:23
  • @Yawar Oh, I didn't know the language isn't finished. There is no warning on official site and version of the language in docs is 8.2.0... – menfon Jan 27 '21 at 05:49
  • That's the compiler version. The syntax version is 0.0.8-dev: https://github.com/rescript-lang/syntax/blob/f6132275a27299dee6b1a1e8f74b22ca70a06e7e/package.json – Yawar Jan 27 '21 at 22:55
  • The language / syntax as it stands is stable, everything else will be an addition to the syntax. There is no "syntax version", there's only a compiler version the syntax is part of. We use git tags to signal shipped syntax versions in the compiler: https://github.com/rescript-lang/syntax/tags – ryyppy Feb 18 '21 at 18:17

1 Answers1

3

As pointed out by @Yawar in the comments, this short-hand is not supported at time of writing, but is likely to be at some point in the future (see https://github.com/rescript-lang/syntax/issues/2 for discussion).

And just to save a click for those coming across this, a workaround is to rewrite it using a local scope and opening the module in that scope:

let testFn = who => {
  open Js
  log("Hello " ++ who ++ "!")
}
glennsl
  • 28,186
  • 12
  • 57
  • 75