Skip to content

Bug: a Candid type whose name matches the generated actor class collides in the wrapper #157

Description

@marc0olo

Independent of #156, but found alongside it.

The generated wrapper declares Candid types and the actor class into the same module scope, so a Candid type whose name equals the derived class name produces a duplicate identifier.

Reproduction

printf 'type My_backend = record { a : nat };\nservice : () -> { test: (My_backend) -> () }\n' > my_backend.did
npx @icp-sdk/bindgen --did-file ./my_backend.did --out-dir ./out --force

out/my_backend.ts:

export interface My_backend {          // from the candid type
export class My_backend implements my_backendInterface {   // from the service name

Both are emitted by add_type_definitions and create_actor_class into one module. Nothing detects the clash.

Notes

Needs a design decision rather than a mechanical fix — either uniquify the class name against the type names in env, or document the limitation and fail generation with a clear error instead of emitting a broken file. Failing loudly seems preferable to silently renaming a public export.

Verified on @icp-sdk/bindgen@0.4.0 and main.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions