-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad error message when importing .did
that isn't a service
#2319
Comments
@stanleygjones not sure if this is counts as a bugfix (not story-worthy), or if it would constitute a developer-facing improvement worth of a few points. |
It's interesting to note that they only reason they were trying to do this is to get access to the installer of an actor, which you can't do except by authoring it as an actor class. Perhaps we should have put the context pattern on the |
Actually, one could argue that this is more an issue for dfx, at least if one follows the philosophy that dfx (by deploying) turns a canister class into a canister instance, and should therefore strip the parameters from the Candid file. But we should still provide a better error message. |
hmm, should this be an error or we can be more permissive that when |
That's the pragmatic, non-principled approach ;-) I think we had that in the thread where we discussed this: conceptually, an IDL for a service instance has no parameters. Whether we strip them in dfx or (implicitly) when parsing is a minor matter of the sort that can cause long and heated debate. |
Yes, please let's not confuse the domains of |
People keep running into this (https://forum.dfinity.org/t/motoko-compiler-bug/5095). We should at least produce a helpful error message. |
That's weird, I too thought this had been fixed (or, at least, the error improved). |
Maybe there was a hard fork in the universe's reality? |
Weird, I also remember there was a PR to improve the error message.... |
I'm with @chenyan-dfinity on this one. If the code is written as a class then importing a canister of that class could just strip the argument. We don't support importing of actor classes via |
The confusion is already baked into to the language design. A class declaration both names the type of its instances (an actor) and the name of a constructor (a function). Canister import can just be interpreted as importing an actor or instance of a class. |
Reminder. |
.did
that isn't a service
…ng the service arguments. (#4041) Allow canister imports of service constructors, silently ignoring the service arguments. A hack that fixes #3990 (for some definition of fix) and duplicate #2319. Really, dfx should be feeding the idl of the instantiated service, not service constructor, to dependent canisters, but until it's fixed to do so (and it hasn't been forever now), this is a reasonable and simple workaround, avoiding the error-prone and kludgy workaround of rewriting candid files described, for instance, here: https://dfinityorg.notion.site/ckBTC-example-Encode-Hackathon-0aaf6292e3404dabb49df5d1b5abc797#08a7469beaf14d6ba35e8827e363e160 and also used here: https://github.com/letmejustputthishere/ckbtc-payments via npm scripting hacks (!). Also see here for the pain this caused: https://forum.dfinity.org/t/confusing-type-error-when-crossing-canisters-expression-of-type-mytype-cannot-produce-expected-type-mytype-1/20636 UPDATE: I turned the previous error into a warning to nag us to fix dfx. UPDATE: Potentially obviated by dfinity/sdk#3138, which teaches dfx to strip the service argument. UPDATE: @chenyan-dfinity thinks we should still merge for other scenarios (old dfx, new compiler, I guess).
Users out there ran into an exception: https://forum.dfinity.org/t/build-error-with-imported-actor-class/1931
They built a canister using
actor class…
, which produced this.did
:which then tripped this code:
These
assert false
should produce more helpful error messages.(Of course, we also should support importing canister classes, but that's a bigger thing; this issue is just about proper error messages.)
The text was updated successfully, but these errors were encountered: