motoko icon indicating copy to clipboard operation
motoko copied to clipboard

bug: `moc` allows declaration of actor method `_motoko_async_helper`

Open crusso opened this issue 3 years ago • 5 comments

... which conflicts with the compiler generated one.

Possible fixes:

  1. reject shared functions called _motoko_async_helper (or more generally, beginning with double underscore, reserving that for compiler generated methods).

  2. choose an inaccessible internal name.

The replica actually use the presence of this caniser method to detect motoko canisters and other tooling might too (icrocks?). Perhaps 1. is a better solution.

c.f. '__get_candid_interface_tmp_hack' and other secret entrypoints.

Repro in #3118

crusso avatar Feb 21 '22 13:02 crusso

The replica actually use the presence of this caniser method to detect motoko canisters and other tooling might too (icrocks?). Perhaps 1. is a better solution.

Sounds like a great reason to use 2 :-D

nomeata avatar Feb 21 '22 15:02 nomeata

There are external apps calling the _get_candid_interface_tmp_hack method, so better to keep that name unchanged.

chenyan-dfinity avatar Feb 21 '22 17:02 chenyan-dfinity

Right! with the async helper, I wouldn't hesitate to change the name. For the candid one, you are absolutely right.

nomeata avatar Feb 21 '22 18:02 nomeata

Shared function ending with one underscore foo_ will generate an corresponding Candid name foo.

Shared function ending with two underscores foo__ will generate an corresponding Candid name foo_ (with one underscore)

three underscores foo___ gives foo__ (with two underscores)

Is this intended (and if so what is its use)?

@crusso @chenyan-dfinity

Web3NL avatar Mar 20 '23 14:03 Web3NL

Yes, it's used to escape reserved keywords in Candid. See https://github.com/dfinity/motoko/blob/master/design/IDL-Motoko.md#type-name-mangling

chenyan-dfinity avatar Mar 20 '23 16:03 chenyan-dfinity