Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .sources/VERSIONS
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ chain-fusion-signer v0.4.0
papi v0.1.1 168bc9d
ic-pub-key v1.0.1 f89fa55
icp-cli v1.1.0 fe4af7c
motoko v1.12.0 ee5391df8
motoko v1.13.0 cd63c2e
motoko-core v2.4.0 cd37dbf
cdk-rs ic-cdk v0.20.1 / ic-cdk-timers v1.0.0 / ic-cdk-executor v2.0.0 317f55c
candid 2025-12-18 # candid v0.10.20, didc v0.5.4 2e4a2cf
Expand Down
2 changes: 1 addition & 1 deletion .sources/motoko
Submodule motoko updated 59 files
+28 −4 .agents/skills/bump-rust-nightly/SKILL.md
+37 −15 .github/prompts/pr-review-prompt.md
+7 −1 .github/workflows/ai-review.yml
+1 −1 .github/workflows/nightly-macos-test.yml
+1 −1 .github/workflows/update-flake-lock-trial.yml
+1 −1 .github/workflows/update-flake-lock.yml
+81 −0 AGENTS.md
+1 −0 CLAUDE.md
+13 −0 Changelog.md
+21 −0 doc/md/fundamentals/modules-imports.md
+4 −1 doc/md/reference/language-manual.md
+9 −9 flake.lock
+1 −1 nix/pkgs.nix
+1 −1 nix/rts.nix
+16 −16 rts/motoko-rts-tests/Cargo.lock
+8 −8 rts/motoko-rts/Cargo.lock
+23 −47 src/codegen/compile_classical.ml
+23 −47 src/codegen/compile_enhanced.ml
+4 −6 src/exes/moc.ml
+8 −3 src/ic/url.ml
+2 −0 src/ic/url.mli
+4 −0 src/ic/url_test.ml
+17 −0 src/idllib/escape.ml
+1 −0 src/idllib/escape.mli
+7 −2 src/lowering/desugar.ml
+0 −1 src/mo_config/flags.ml
+12 −0 src/mo_def/syntax.ml
+1 −4 src/mo_frontend/typing.ml
+76 −18 src/mo_idl/idl_to_mo.ml
+1 −0 src/mo_interpreter/interpret.ml
+26 −10 src/pipeline/pipeline.ml
+9 −4 src/pipeline/resolve_import.ml
+24 −0 src/pipeline/resolve_import_test.ml
+1 −1 test/bench/ok/candid-subtype-cost.drun-run.ok
+6 −6 test/bench/ok/typtbl.drun-run.ok
+8 −0 test/fail/import-local-did-call.mo
+3 −0 test/fail/import-local-did-call/service.did
+6 −0 test/fail/import-local-did-no-service.mo
+1 −0 test/fail/import-local-did-no-service/types.did
+6 −0 test/fail/import-local-did-self.mo
+4 −0 test/fail/import-local-did-self/service.did
+5 −0 test/fail/ok/import-local-did-call.tc-human.ok
+1 −0 test/fail/ok/import-local-did-call.tc-human.ret.ok
+2 −0 test/fail/ok/import-local-did-call.tc.ok
+1 −0 test/fail/ok/import-local-did-call.tc.ret.ok
+4 −0 test/fail/ok/import-local-did-no-service.tc-human.ok
+1 −0 test/fail/ok/import-local-did-no-service.tc-human.ret.ok
+1 −0 test/fail/ok/import-local-did-no-service.tc.ok
+1 −0 test/fail/ok/import-local-did-no-service.tc.ret.ok
+4 −0 test/fail/ok/import-local-did-self.tc-human.ok
+1 −0 test/fail/ok/import-local-did-self.tc-human.ret.ok
+1 −0 test/fail/ok/import-local-did-self.tc.ok
+1 −0 test/fail/ok/import-local-did-self.tc.ret.ok
+15 −0 test/run-drun/import-local-did-dual.mo
+4 −0 test/run-drun/import-local-did-dual/aaaaa-aa.did
+16 −0 test/run/import-local-did-collision.mo
+10 −0 test/run/import-local-did-collision/service.did
+15 −0 test/run/import-local-did.mo
+7 −0 test/run/import-local-did/service.did
21 changes: 21 additions & 0 deletions docs/languages/motoko/fundamentals/modules-imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,27 @@ When importing from another canister, the canister must be listed as a dependenc

:::

## Importing a local `.did` file

A Candid interface file can be imported with the `idl:` URI scheme to get Motoko **types only**: not a canister handle:

```motoko no-repl
import S "idl:interfaces/ledger.did";

type Ledger = S.Self; // actor { ... } from the Candid service
type Account = S.Account; // named Candid types (PascalCased when unambiguous)
```

`S` is a module of type aliases (only types declared in that `.did` file, not transitive Candid imports). It cannot be used to call methods. For a live reference, use a separate `canister:` / `ic:` import, or `actor "<principal>" : S.Self`. Types-only and actor imports of the same `.did` path are distinct and can be used together.

As with any module import, a pattern can bind selected types directly:

```motoko no-repl
import { type Self; type Account } "idl:interfaces/ledger.did";
```

Snake_case Candid type names are exported in PascalCase when that does not collide with another type in the same file (`user_id` → `UserId`). If both `user_id` and `UserId` exist, both keep their original names. Names that do not start with a lowercase letter (`HTTP_request`, `_internal`) are kept as-is.

## Importing actor classes

When imported, an [actor](./actors/actors-async.md) class provides a type definition describing the class interface and a function that returns an instance of the class.
Expand Down
13 changes: 13 additions & 0 deletions docs/languages/motoko/reference/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ sidebar:

# Motoko compiler changelog

## 1.13.0 (2026-08-03)

* motoko (`moc`)

* feat: import a local Candid file as a types-only Motoko module via the `idl:` URI scheme —
`import S "idl:foo.did"` exposes `S.Self` (the service actor type) and named
Candid types, PascalCased when unambiguous (e.g. `user_id` → `S.UserId`). No principal or
`--actor-idl` flags required (#6263).

* chore: multi-value Wasm codegen is now always on;
`--(no-)experimental-multi-value` are kept for CLI compatibility but have
no effect (#6266).

## 1.12.0 (2026-07-30)

* motoko (`moc`)
Expand Down
5 changes: 4 additions & 1 deletion docs/languages/motoko/reference/language-manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,10 @@ The syntax of an **import** `<imp>` is as follows:
"ic:<canisterid>" Import external actor by <canisterid>
"canister:<name>" Import external actor by <name>
"blob:file:<filepath>" Import literal `Blob` value from <filepath>
"idl:<filepath>" Import types-only module from Candid <filepath>
```

An import introduces a resource referring to a local source module, module from a package of modules, a canister imported as an actor, or a literal [`Blob`](#type-blob) value. The contents of the resource are bound to `<pat>`.
An import introduces a resource referring to a local source module, module from a package of modules, a canister imported as an actor, a types-only module from a Candid IDL file, or a literal [`Blob`](#type-blob) value. The contents of the resource are bound to `<pat>`.

Though typically a simple identifier, `<id>`, `<pat>` can also be any composite pattern binding selective components of the resource.

Expand Down Expand Up @@ -1362,6 +1363,8 @@ In detail, if `<url>` is of the form:
- `"blob:file:<filepath>"` then `<pat>` is bound to a blob containing the contents of the file `<filepath>`. `<filepath>` is interpreted relative to the absolute location of the enclosing file. For example, `import image "blob:file:/assets/image.jpg"` defines `image` as the blob with bytes from local file `./assets/image.jpg`. Unlike library imports, `<filepath>` should include the
file's extension, if any.

- `"idl:<filepath>"` then `<pat>` is bound to a types-only Motoko module derived from the Candid IDL file at `<filepath>`: type field `Self` is the service actor type, and each named Candid type declared in that file is exported (PascalCased when unambiguous). `<filepath>` is interpreted relative to the absolute location of the enclosing file and should include the extension (typically `.did`). For example, `import S "idl:api/ledger.did"` defines `S` with `S.Self` and related type aliases. This import cannot be used to call methods; use `ic:` / `canister:` (or `actor "<principal>" : S.Self`) for a live reference.

The case sensitivity of file references depends on the host operating system so it is recommended not to distinguish resources by filename casing alone.

When building multi-canister projects with the [IC SDK](https://github.com/dfinity/sdk), Motoko programs can typically import canisters by alias (e.g. `import C "canister:counter"`), without specifying low-level canister ids (e.g. `import C "ic:lg264-qjkae"`). The SDK tooling takes care of supplying the appropriate command-line arguments to the Motoko compiler.)
Expand Down
Loading