fix: add Char pattern matching and Char comparison operators

- Parser: support Char literals in match patterns (e.g., 'x' => ...)
- Interpreter: add Char comparison for <, <=, >, >= operators
  Previously only Int, Float, and String supported ordering comparisons.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-17 08:25:15 -05:00
parent d26fd975d1
commit e3b6f4322a
2 changed files with 12 additions and 0 deletions

View File

@@ -1887,6 +1887,14 @@ impl Parser {
span: token.span,
}))
}
TokenKind::Char(c) => {
let c = *c;
self.advance();
Ok(Pattern::Literal(Literal {
kind: LiteralKind::Char(c),
span: token.span,
}))
}
TokenKind::Ident(name) => {
// Check if it starts with uppercase (constructor) or lowercase (variable)
if name.chars().next().map_or(false, |c| c.is_uppercase()) {