Language reference · section 21
21. Decorators
The decorators are @wasm, @worker, and @memo. A decorator sits on its own line, directly above a fn.
Feature: Decorators
Scenario: A decorator applies a compile-time transform
Given a line "@name" above a fn
Then the compiler applies the transform named name to the function
Scenario: An unknown decorator is an error
Given the decorator @foo on a function f
Then the compiler reports an error "unknown decorator @foo on function f"
Scenario: Only @worker takes options
Given the decorator @wasm(x: 1)
Then the compiler reports an error "@wasm takes no options, but `x` was given"
Scenario: pool is the only @worker option
Given the decorator @worker(size: 2)
Then the compiler reports an error "unknown option `size` on @worker; the only option is `pool`"
Scenario: @memo cannot be combined with @wasm
Given the decorators @memo and @wasm on one function
Then the compiler reports an error "@memo cannot be combined with @wasm yet"
Scenario: @memo cannot be combined with @worker
Given the decorators @memo and @worker on one function
Then the compiler reports an error "@memo cannot be combined with @worker yet"
Scenario: @wasm and @worker can be combined
Given the decorators @worker and @wasm on one function
Then each worker loads the module's WebAssembly and runs it