You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A contract operation signature requires at least one parameter. There is no
way to declare a zero-argument operation: both the empty-parameter-list form name: () -> ReturnType and the bare-arrow form name: -> ReturnType fail to
parse. This forces a nominal dummy parameter as a workaround.
Why it matters
Zero-argument operations are common at integration boundaries: listing all
items, fetching global state, health checks. When modelling such a boundary as
a contract (the language's recommended construct for code-to-code surfaces per
patterns.md Pattern 9), every parameterless operation has to carry a fake
argument, which leaks an implementation artefact into the spec and makes a
signature-level comparison against the real API noisier.
b-bare-arrow.allium: same file, signature line replaced with list_things: -> Set<Foo>.
Expected behaviour
At least one of the two forms parses and declares a zero-argument operation
returning Set<Foo>. (name: () -> ReturnType is the conventional choice in
most signature grammars.)
Actual behaviour
Both forms produce a parse error on the signature line:
What goes wrong
A
contractoperation signature requires at least one parameter. There is noway to declare a zero-argument operation: both the empty-parameter-list form
name: () -> ReturnTypeand the bare-arrow formname: -> ReturnTypefail toparse. This forces a nominal dummy parameter as a workaround.
Why it matters
Zero-argument operations are common at integration boundaries: listing all
items, fetching global state, health checks. When modelling such a boundary as
a
contract(the language's recommended construct for code-to-code surfaces perpatterns.md Pattern 9), every parameterless operation has to carry a fake
argument, which leaks an implementation artefact into the spec and makes a
signature-level comparison against the real API noisier.
Steps to reproduce
a-empty-parens.allium:Run
allium check a-empty-parens.allium.b-bare-arrow.allium: same file, signature line replaced withlist_things: -> Set<Foo>.Expected behaviour
At least one of the two forms parses and declares a zero-argument operation
returning
Set<Foo>. (name: () -> ReturnTypeis the conventional choice inmost signature grammars.)
Actual behaviour
Both forms produce a parse error on the signature line:
() -> ...producesexpected expression (identifier, number, string, true/false, null, if/for/not/exists, '(', '{', '['), found ')'-> ...producesexpected expression (...), found '->'The parser treats the contract signature body as an expression position and
expects a parameter expression where the empty list or arrow appears.
Workaround
A nominal unit parameter parses cleanly:
This is what we are using in production specs, but
_unit: Anyis noise thatexists only to satisfy the grammar.
Environment
allium 3.2.3 (language versions: 1, 2, 3)-- allium: 3Out of scope
Anyshould be discouraged elsewhereRelated
skills/allium/references/language-reference.md(Contracts section)skills/allium/references/patterns.md