Skip to content

♻️ refactor(lang): change Number::to_int() to return i64 instead of u64#1317

Merged
harehare merged 2 commits intofeat/shift-header-levelfrom
copilot/sub-pr-1315
Feb 21, 2026
Merged

♻️ refactor(lang): change Number::to_int() to return i64 instead of u64#1317
harehare merged 2 commits intofeat/shift-header-levelfrom
copilot/sub-pr-1315

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 21, 2026

Number::to_int() returned u64, which caused silent wrapping for negative values (e.g. -1.0 as u64 produces a very large number) and was inconsistent with how Number already uses i64 in its Display impl.

Changes

  • number.rs: to_int() now returns i64 via self.0 as i64
  • builtin.rs: Heading depth callers updated to clamp safely with .max(0).min(u8::MAX as i64) as u8, preventing negative shift amounts from producing incorrect u8 values
// Before: negative shift amounts would silently wrap to large u64/u8 values
pub fn to_int(self) -> u64 { self.0 as u64 }

// After: preserves sign; callers clamp to valid range explicitly
pub fn to_int(self) -> i64 { self.0 as i64 }

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add left shift and right shift token kinds and operations ♻️ refactor(lang): change Number::to_int() to return i64 instead of u64 Feb 21, 2026
Copilot AI requested a review from harehare February 21, 2026 23:20
@harehare harehare marked this pull request as ready for review February 21, 2026 23:21
@harehare harehare merged commit ddbf804 into feat/shift-header-level Feb 21, 2026
@harehare harehare deleted the copilot/sub-pr-1315 branch February 21, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants