From 37d0bc59d2993d8c9ce1aa6fb27b366d00e99c9b Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 14:17:47 +0800 Subject: [PATCH 1/9] promote --- .github/workflows/codecov.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codecov.yaml b/.github/workflows/codecov.yaml index 33870f8..669d1e6 100644 --- a/.github/workflows/codecov.yaml +++ b/.github/workflows/codecov.yaml @@ -23,7 +23,7 @@ jobs: run: | moon version --all moon update - moon install + moon check --deny-warn - name: Run tests with coverage run: | From 48eaa35ff797839e99d1d5dbc261212b35fcfcdc Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 14:18:54 +0800 Subject: [PATCH 2/9] replace deprecated Show derives --- ini_file.mbt | 24 ++++++++++++++++++++++-- parser.mbt | 28 ++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/ini_file.mbt b/ini_file.mbt index a6d4aca..9b40f47 100644 --- a/ini_file.mbt +++ b/ini_file.mbt @@ -2,13 +2,33 @@ priv enum Section { Global NamedSection(String) -} derive(Eq, Hash, Show) +} derive(Eq, Hash) + +///| +impl Show for Section with output(self, logger) { + match self { + Section::Global => logger.write_string("Global") + Section::NamedSection(name) => { + logger.write_string("NamedSection(") + name.output(logger) + logger.write_string(")") + } + } +} ///| priv struct Key(String) derive(Eq, Hash) ///| -priv struct Value(String) derive(Show) +priv struct Value(String) + +///| +impl Show for Value with output(self, logger) { + let Value(value) = self + logger.write_string("Value(") + value.output(logger) + logger.write_string(")") +} ///| struct IniFile { diff --git a/parser.mbt b/parser.mbt index 17e0e7e..e6fb5f1 100644 --- a/parser.mbt +++ b/parser.mbt @@ -23,7 +23,16 @@ priv enum ReadingValueState { None SingleQuote DoubleQuote -} derive(Show) +} + +///| +impl Show for ReadingValueState with output(self, logger) { + match self { + ReadingValueState::None => logger.write_string("None") + ReadingValueState::SingleQuote => logger.write_string("SingleQuote") + ReadingValueState::DoubleQuote => logger.write_string("DoubleQuote") + } +} ///| priv enum ParsePhase { @@ -32,7 +41,22 @@ priv enum ParsePhase { ReadingKey ReadingValue(ReadingValueState) InComment -} derive(Show) +} + +///| +impl Show for ParsePhase with output(self, logger) { + match self { + ParsePhase::Start => logger.write_string("Start") + ParsePhase::ReadingSection => logger.write_string("ReadingSection") + ParsePhase::ReadingKey => logger.write_string("ReadingKey") + ParsePhase::ReadingValue(state) => { + logger.write_string("ReadingValue(") + state.output(logger) + logger.write_string(")") + } + ParsePhase::InComment => logger.write_string("InComment") + } +} ///| priv struct EscapeStateHex { From b923e159e1f1a601241dc536078905c366122643 Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 14:19:08 +0800 Subject: [PATCH 3/9] replace deprecated not calls --- ini_file.mbt | 2 +- parser.mbt | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ini_file.mbt b/ini_file.mbt index 9b40f47..36d58e0 100644 --- a/ini_file.mbt +++ b/ini_file.mbt @@ -172,7 +172,7 @@ pub fn IniFile::to_string(self : IniFile) -> String { '#' => "\\#" '=' => "\\=" ':' => "\\:" - _ if c.is_control() || c.is_whitespace() || not(c.is_printable()) => { + _ if c.is_control() || c.is_whitespace() || !c.is_printable() => { let unicode = c.to_int().to_string(radix=16) guard unicode.length() <= 4 else { abort("Unicode escape sequence too long") diff --git a/parser.mbt b/parser.mbt index e6fb5f1..5e61345 100644 --- a/parser.mbt +++ b/parser.mbt @@ -208,7 +208,7 @@ fn IniParseState::handle_section_char( let section_name = self.ctx.buffer.to_string().trim() let section_name = self.lower_if_needed(section_name.to_string()) self.ctx.current_section = Section::NamedSection(section_name) - if not(self.ctx.sections.contains(self.ctx.current_section)) { + if !self.ctx.sections.contains(self.ctx.current_section) { self.ctx.sections.set(self.ctx.current_section, @hashmap.new()) } self.phase = Start @@ -245,7 +245,7 @@ fn IniParseState::handle_key_char( } '\n' | ';' | '#' => { let key = self.ctx.buffer.to_string().trim() - if not(key.is_empty()) { + if !key.is_empty() { let key = self.lower_if_needed(key.to_string()) self.ctx.key = key self.ctx.buffer.reset() @@ -323,7 +323,7 @@ fn IniParseState::handle_value_char( } if c == '\\' { self.escape_state = EscapeState::Escape - self.last_char_is_backslash = not(self.last_char_is_backslash) // handle consecutive backslashes + self.last_char_is_backslash = !self.last_char_is_backslash // handle consecutive backslashes return self } match c { @@ -386,7 +386,7 @@ fn IniParseState::handle_value_char( _ if c.is_whitespace() => { match self.phase { ReadingValue(ReadingValueState::None) => - if not(self.ctx.buffer.is_empty()) { + if !self.ctx.buffer.is_empty() { self.ctx.buffer.write_char(c) } ReadingValue(ReadingValueState::SingleQuote) => @@ -437,7 +437,7 @@ fn IniParseState::commit_value( } let section = self.ctx.sections.get(self.ctx.current_section).unwrap() let key = self.ctx.key - guard not(key.is_blank()) else { + guard !key.is_blank() else { raise IniParseError::ValueWithoutSection( line=self.ctx.line, col=self.ctx.col, From 863319b5b10442e236adff321aee707b8588187b Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 14:19:20 +0800 Subject: [PATCH 4/9] replace ignored cascade calls --- ini_file.mbt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ini_file.mbt b/ini_file.mbt index 36d58e0..fd716d8 100644 --- a/ini_file.mbt +++ b/ini_file.mbt @@ -277,7 +277,7 @@ test "INIFile::get/basic_functionality" { test "INIFile::get/case_sensitivity" { let ini = { let temp = IniFile::new(is_case_sensitive=true) - temp..set(section="Section", "Key", "value") + temp.set(section="Section", "Key", "value") temp } inspect(ini.get(section="Section", "Key"), content="Some(\"value\")") @@ -289,8 +289,8 @@ test "INIFile::get/case_sensitivity" { test "INIFile::get/empty_strings" { let ini = { let temp = IniFile::new() - temp..set(section="", "key", "value") - temp..set(section="section", "", "value") + temp.set(section="", "key", "value") + temp.set(section="section", "", "value") temp } inspect(ini.get(section="", "key"), content="Some(\"value\")") @@ -301,12 +301,12 @@ test "INIFile::get/empty_strings" { test "INIFile::get_bool/true_values" { let ini = { let obj = IniFile::new() - obj..set("key1", "true") - obj..set("key2", "yes") - obj..set("key3", "on") - obj..set(section="test", "key4", "TRUE") - obj..set(section="test", "key5", "Yes") - obj..set(section="test", "key6", "ON") + obj.set("key1", "true") + obj.set("key2", "yes") + obj.set("key3", "on") + obj.set(section="test", "key4", "TRUE") + obj.set(section="test", "key5", "Yes") + obj.set(section="test", "key6", "ON") obj } inspect(ini.get_bool("key1"), content="Some(true)") From 5063d0b63ef18155508c58b036780c79b30ab4ab Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 14:19:45 +0800 Subject: [PATCH 5/9] replace raising callbacks with arrows --- ini_file.mbt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ini_file.mbt b/ini_file.mbt index fd716d8..0294f49 100644 --- a/ini_file.mbt +++ b/ini_file.mbt @@ -407,7 +407,7 @@ test "INIFile::to_string/escape_special_characters" { let ini1 = IniFile::new() kvs .iter() - .each(fn(kv) { + .each((kv) => { let (key, value) = kv sections.iter().each(fn(section) { ini1.set(section~, key, value) }) }) @@ -415,11 +415,11 @@ test "INIFile::to_string/escape_special_characters" { let ini2 = parse(output) kvs .iter() - .each(fn(kv) { + .each((kv) => { let (key, _) = kv sections .iter() - .each(fn(section) { + .each((section) => { let ini1_value = ini1.get(section~, key) let ini2_value = ini2.get(section~, key) inspect(ini1_value == ini2_value, content="true") From 1eb756eb778dd7d5b18220c0de1a9f75bfb501ec Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 14:20:13 +0800 Subject: [PATCH 6/9] replace deprecated parse int API --- moon.pkg.json | 2 +- parser.mbt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/moon.pkg.json b/moon.pkg.json index 9de829d..b234151 100644 --- a/moon.pkg.json +++ b/moon.pkg.json @@ -1,6 +1,6 @@ { "import": [ "moonbitlang/core/hashmap", - "moonbitlang/core/strconv" + "moonbitlang/core/string" ] } diff --git a/parser.mbt b/parser.mbt index 5e61345..207d04b 100644 --- a/parser.mbt +++ b/parser.mbt @@ -280,7 +280,7 @@ fn IniParseState::handle_value_char( state.left -= 1 if state.left == 0 { // it must be 4 digits hex - let code = try! @strconv.parse_int(state.hex.to_string(), base=16) + let code = try! @string.parse_int(state.hex.to_string(), base=16) self.ctx.buffer.write_char(Int::unsafe_to_char(code)) self.escape_state = EscapeState::None self.last_char_is_backslash = false From 95a65d7f6e9825cb64cfd26c65676c833e396ff8 Mon Sep 17 00:00:00 2001 From: myfreess Date: Wed, 22 Apr 2026 14:20:33 +0800 Subject: [PATCH 7/9] moon fmt --- ini_file.mbt | 6 +++--- moon.pkg | 4 ++++ moon.pkg.json | 6 ------ 3 files changed, 7 insertions(+), 9 deletions(-) create mode 100644 moon.pkg delete mode 100644 moon.pkg.json diff --git a/ini_file.mbt b/ini_file.mbt index 0294f49..a3874f9 100644 --- a/ini_file.mbt +++ b/ini_file.mbt @@ -407,7 +407,7 @@ test "INIFile::to_string/escape_special_characters" { let ini1 = IniFile::new() kvs .iter() - .each((kv) => { + .each(kv => { let (key, value) = kv sections.iter().each(fn(section) { ini1.set(section~, key, value) }) }) @@ -415,11 +415,11 @@ test "INIFile::to_string/escape_special_characters" { let ini2 = parse(output) kvs .iter() - .each((kv) => { + .each(kv => { let (key, _) = kv sections .iter() - .each((section) => { + .each(section => { let ini1_value = ini1.get(section~, key) let ini2_value = ini2.get(section~, key) inspect(ini1_value == ini2_value, content="true") diff --git a/moon.pkg b/moon.pkg new file mode 100644 index 0000000..a2e7696 --- /dev/null +++ b/moon.pkg @@ -0,0 +1,4 @@ +import { + "moonbitlang/core/hashmap", + "moonbitlang/core/string", +} \ No newline at end of file diff --git a/moon.pkg.json b/moon.pkg.json deleted file mode 100644 index b234151..0000000 --- a/moon.pkg.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "import": [ - "moonbitlang/core/hashmap", - "moonbitlang/core/string" - ] -} From 5dab1630c887f4d71352805b9c9d304d51405d8a Mon Sep 17 00:00:00 2001 From: myfreess Date: Sun, 26 Apr 2026 19:00:39 +0800 Subject: [PATCH 8/9] update ci --- .github/workflows/check.yaml | 43 --------------------------------- .github/workflows/check.yml | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/check.yaml create mode 100644 .github/workflows/check.yml diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml deleted file mode 100644 index 5d063ef..0000000 --- a/.github/workflows/check.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: Check and Test -on: - pull_request: - push: - branches: - - "main" - -jobs: - build: - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: install-ubuntu - if: ${{ matrix.os != 'windows-latest' }} - run: | - curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash - echo "$HOME/.moon/bin" >> $GITHUB_PATH - - name: install-windows - if: ${{ matrix.os == 'windows-latest' }} - run: | - Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex - "C:\Users\runneradmin\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append - - - name: post install - run: | - moon version --all - moon update - - - name: moon check - run: | - moon check --target all - - - name: moon test - run: | - moon test --target all - - - name: lint - run: | - moon fmt && git diff --exit-code - moon info && git diff --exit-code diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..485b268 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,47 @@ +name: check + +on: + push: + branches: + - master + - main + pull_request: + +jobs: + check: + strategy: + fail-fast: false + runs-on: ubuntu-latest + continue-on-error: false + steps: + - uses: actions/checkout@v4 + with: + submodules: 'recursive' + + - name: install + run: | + curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash + echo "$HOME/.moon/bin" >> $GITHUB_PATH + + - name: moon version + run: | + moon version --all + + - name: moon check + run: | + moon update + moon check --deny-warn + + - name: moon info + run: | + moon info --target all + git diff --exit-code + + - name: format diff + run: | + moon fmt + git diff --exit-code + + - name: moon test + run: | + moon test --target all From e98a2dc2037badf20c31cc42503fc1562d43eb3d Mon Sep 17 00:00:00 2001 From: myfreess Date: Sun, 26 Apr 2026 19:01:01 +0800 Subject: [PATCH 9/9] moon fmt --- moon.pkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moon.pkg b/moon.pkg index a2e7696..494b4e5 100644 --- a/moon.pkg +++ b/moon.pkg @@ -1,4 +1,4 @@ import { "moonbitlang/core/hashmap", "moonbitlang/core/string", -} \ No newline at end of file +}