rescript-lang.org icon indicating copy to clipboard operation
rescript-lang.org copied to clipboard

Compiler error when using @meth

Open hariroshan opened this issue 4 years ago • 2 comments

There is a compiler error thrown when using @meth decorator.

This expression has type Js_OO.Meth.arity1<array<int> => bool>
  It is not a function.

Rescript version: 9.1.2

But the code compiles in version 9.0.2. Can you verify?

https://rescript-lang.org/try?code=C4TwDgpgBAhgTnGIBMAeA5DAfFAvFAbwCgooABAWwmAAsSoAiASwGcBBBJBgLlk5FRMAdsBy4cAIwD2UgDZEAvkTIsAxlMgAKBgHdhAEyk6GASnIA3GLKgQAHsAhwhVvohS94btMNF5GHNwYiWWooYTAAV2A-AG0ARgBdYNDbP08kZGTokD9bGOZ2fgYEzXCokyIgA

hariroshan avatar May 16 '21 12:05 hariroshan

This is reproducible for me as well.

Syntax Lookup example code for @meth also shows this error.

Removing the @meth decorator appears to resolve the issue.

Not sure if the docs need to be updated, or this should be raised as a compiler issue?

kevanstannard avatar May 18 '21 10:05 kevanstannard

9.1.2 basically made the original @meth semantics inaccessible from our syntax (/cc @IwanKaramazow), because the compiler unified Js.t with structural objects. To represent method calls, you kinda need to use @send external instead (at least for now, not sure if we want to introduce dedicated syntax for method calls).

This needs to be updated in the docs

ryyppy avatar May 19 '21 05:05 ryyppy

This actually compiles again in v11. Closing...

fhammerschmidt avatar Mar 09 '24 23:03 fhammerschmidt