Skip to content
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

Funcs break init method #1474

Closed
dansteren opened this issue Dec 7, 2023 · 2 comments · Fixed by #1492
Closed

Funcs break init method #1474

dansteren opened this issue Dec 7, 2023 · 2 comments · Fixed by #1492
Labels
bug A known issue where behavior deviates from expectations

Comments

@dansteren
Copy link
Contributor

Given the following canister:

import { bool, Canister, Func, init, nat16 } from 'azle';

const SimpleFunc = Func([bool], nat16, 'query');

export default Canister({
    init: init([SimpleFunc], () => {})
});

When running dfx build,
Then the following canister is generated:

service: (func (bool) -> {

}

Resulting in the following error:

Building canisters...
Executing 'npx azle canister'

Building canister canister

Done in 3.41s

🎉 Built canister canister at .azle/canister/canister.wasm

error: parser error
  ┌─ /src/index.did:1:26
  │
1 │ service: (func (bool) -> {
  │                          ^ Unexpected token
  │
  = Expects "("

Error: Failed while trying to build all canisters.
Caused by: Failed while trying to build all canisters.
  The post-build step failed for canister 'bkyz2-fmaaa-aaaaa-qaaaq-cai' (canister) with an embedded error: Candid file check failed for /src/index.did.: Candid parser error: Unrecognized token `LBrace` found at 25:26
Expected one of "(": Unrecognized token `LBrace` found at 25:26
Expected one of "("
@dansteren dansteren added the bug A known issue where behavior deviates from expectations label Dec 7, 2023
@bdemann
Copy link
Member

bdemann commented Jan 8, 2024

To clarify the candid we would expect to be generated from this canister is

service: (func (bool)) -> {

}

So we're just missing an extra ) after bool

@bdemann
Copy link
Member

bdemann commented Jan 9, 2024

The actual problem was that it was dropping everything after the -> because of how the service visitor works, after updating that I think it should work. Or in other words, my previous comment is wrong because we are also missing the return type of that func

@bdemann bdemann linked a pull request Jan 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A known issue where behavior deviates from expectations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants