docs

您正在閱讀 v0.1.0 的文件。Nabi 0.1.0 已停止支援。 最新版本:v0.1.3 →

本頁尚未翻譯,以下為英文原文。

#E0116: malformed macro definition

A macro's rules are not well formed. Each rule is ( matcher ) => { template }, a metavariable is @name: fragment, and a repetition is @rep[sep = ","] { .. }.

nabi
#[impl_macro(twice)] @macro {
    @e: expr => { (@e, @e) }
}
let p = twice!(3);
error[E0116]: a macro rule starts with `( matcher )`
  --> main.nabi:2:5
   |
 2 |     @e: expr => { (@e, @e) }
   |     ^

Wrap the matcher in parentheses:

nabi
#[impl_macro(twice)] @macro {
    ( @e: expr ) => { { let v = @e; (v, v) } }
}
let p = twice!(3);
println(f"{p.0 + p.1}");
6

See 6.8.12 The macro form.

Related: E0117 no macro rule matches, E0118 invalid meta template

Found a mistake? Edit this page on GitHub. Last updated