docs

#E0006: 字面值中無效的跳脫序列

字串或字元字面值中的 \ 跳脫序列不是 Nabi 認得的,或是位元組字串中有它無法容納的字元。可用的跳脫序列有 \n、\r、\t、\0、\\、\'、\"、\xHH 和 \u{..};位元組字串只能容納 ASCII,其他位元組請寫成 \xHH(最大為 \xFF)。

nabi
println("100\% done");
error[E0006]: unknown escape sequence `\%`
  --> main.nabi:1:13
   |
 1 | println("100\% done");
   |             ^^
   |
   = help: the escapes are `\n` `\r` `\t` `\0` `\\` `\'` `\"` `\xHH` `\u{..}`; `%` needs no escape, so write `%` (or `\\%` for a backslash and `%`)

% 不需要跳脫。要寫出反斜線本身,請寫 \\。

nabi
println("100% done");
100% done

相關錯誤碼:E0005 未結束的字面值或註解、E0007 字元字面值只能容納一個字元

發現錯誤? 在 GitHub 上編輯此頁 最後更新: