Skip to content

Commit a2327aa

Browse files
authored
fix(moonbit): Update keywords (#1282)
* fix(moonbit): Update keywords * fix(moonbit): init and main are reserved
1 parent c9b4d14 commit a2327aa

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

crates/moonbit/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2871,13 +2871,16 @@ trait ToMoonBitIdent: ToOwned {
28712871

28722872
impl ToMoonBitIdent for str {
28732873
fn to_moonbit_ident(&self) -> String {
2874-
// Escape MoonBit keywords
2874+
// Escape MoonBit keywords and reserved keywords
28752875
match self {
2876-
"continue" | "for" | "match" | "if" | "pub" | "priv" | "readonly" | "break"
2877-
| "raise" | "try" | "except" | "catch" | "else" | "enum" | "struct" | "type"
2878-
| "trait" | "return" | "let" | "mut" | "while" | "loop" | "extern" | "with"
2879-
| "throw" | "init" | "main" | "test" | "in" | "guard" | "typealias" | "const"
2880-
| "method" | "move" | "do" | "static" | "final" => {
2876+
"module" | "move" | "ref" | "static" | "super" | "unsafe" | "use" | "where"
2877+
| "await" | "dyn" | "abstract" | "do" | "final" | "macro" | "override" | "typeof"
2878+
| "virtual" | "yield" | "local" | "method" | "alias" | "assert" | "as" | "else"
2879+
| "extern" | "fn" | "if" | "let" | "const" | "match" | "mut" | "type" | "typealias"
2880+
| "struct" | "enum" | "trait" | "traitalias" | "derive" | "while" | "break"
2881+
| "continue" | "import" | "return" | "throw" | "raise" | "try" | "catch" | "pub"
2882+
| "priv" | "readonly" | "true" | "false" | "_" | "test" | "loop" | "for" | "in"
2883+
| "impl" | "with" | "guard" | "async" | "is" | "init" | "main" => {
28812884
format!("{self}_")
28822885
}
28832886
_ => self.to_snake_case(),

0 commit comments

Comments
 (0)