Skip to content

feat: support func-fields (moc#6184) - #37

Draft
ggreif wants to merge 2 commits into
mainfrom
gabor/func-fields
Draft

ggreif wants to merge 2 commits into
mainfrom
gabor/func-fields

Conversation

@ggreif

@ggreif ggreif commented Jun 18, 2026 •

Copy link
Copy Markdown

Companion to caffeinelabs/motoko#6184 — func-field syntax (func name(args) : T <body>).

Depends on caffeinelabs/tree-sitter-motoko#12; Cargo.toml pins its PR ref — re-pin to the merged rev before merging. 23/23 green, no behavior change.

ggreif and others added 2 commits June 18, 2026 11:30
Bump the tree-sitter-motoko dependency to caffeinelabs/tree-sitter-motoko#12
(func-fields grammar), so records using `func name(args) : T <body>` fields
parse cleanly instead of emitting ERROR nodes that silently corrupt the tree.

- Cargo.toml: point at the func-fields PR ref (re-pin to the merged rev once #12 lands)
- test-data.mo: func-field samples (plain, block-body, with-extension)
- snapshots: line-number shifts only — no rule fires on func-fields, no behavior change

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Three example rules that contract verbose lambda-fields into the func-field
sugar (moc#6184): `name = func(...) …` → `func name(...) …`.

- func-field-sugar          plain expr body
- func-field-sugar-block    block body
- func-field-sugar-generic  type-parametric (preserves `<T>`)

The plain/block rules use `!typ_params` so they never clobber a generic field;
the generic rule captures and re-emits `typ_params`. `async`/`async*` ride
along transparently in `return_ty`/the rhs. Exercised by the example-rules
snapshot tests over new `test-data.mo` fixtures. Suite green (23/23).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@caffeine-ci-bot

Copy link
Copy Markdown
Contributor

This draft pull request has had no activity for 60 days and has been marked as stale. It will not be closed automatically. Please close it if you can.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant