bug: `moc` allows declaration of actor method `_motoko_async_helper`
... which conflicts with the compiler generated one.
Possible fixes:
-
reject shared functions called _motoko_async_helper (or more generally, beginning with double underscore, reserving that for compiler generated methods).
-
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
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
There are external apps calling the _get_candid_interface_tmp_hack method, so better to keep that name unchanged.
Right! with the async helper, I wouldn't hesitate to change the name. For the candid one, you are absolutely right.
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
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