With SDK v.0.6.10 I see the following build type error:
type error, an actor or actor class must be the only non-imported declaration in a program
There is also a hint saying
(This is a limitation of the current version.)
What is a non-imported declaration in a program? I am copying and pasting the code from the tutorial mutiple actors.
I’m pretty sure you need to move the type and function declarations inside your actor in
source/assistant/main.mo. Tagging @alexa.smith to propagate this change to the Tutorial
That was it. Thanks @cryptoschindler.
It works if the type declaration ToDo and functions add and show are in the actor block after the variables todos and nextId have been declared. I wanted to paste the full actor snippet but received a 403.
Same applies to the Adding a stylesheet tutorial. The contacts.mo type declarations need to be within the actor block.
I still have no clue how motoko works except for that.
Thanks @factorlive and @cryptoschindler for these catches! Our docs are open source, so please feel free to open PRs when you find fixes like these: https://github.com/dfinity/docs. I’ve also passed along to the team.
Ok @alexa.smith. Well, I did this for linkedup now. Hope this is still the right way as obviously somebody did like to declare types before that coder got started with the actor block according to the examples.
Thanks Patrick, I think we’d all been organising things this way, with the types outside, it’s only a very recent change to the sdk that prohibited it…!
Static typing fashion is en vogue for a reason and can make actors much more maintainable. So thanks for outlining all the concepts in detail in the documentation. It is a good read.