gleam-lang/gleam · error
Radix not implemented
Error message
Radix not implemented: {other} What it means
An internal lexer panic in Gleam: `is_digit_of_radix` (compiler-core/src/parse/lexer.rs) only supports radices 2, 8, 10, and 16 for numeric literal scanning, and panics on any other radix value. It signals a programmer error — a caller passed an unsupported radix, likely after a lexer change adding a new numeric literal form.
Solutions
- Fix the call site to pass only a supported radix (2, 8, 10, 16) for the literal being lexed.
- If a new radix is genuinely needed, add it to the `match radix` arm list instead of panicking.
- Report the panic with the input file if encountered in an unmodified Gleam build.
Example fix
// before
match radix {
2 | 8 | 10 | 16 => c.filter(|c| c.is_digit(radix)).is_some(),
other => panic!("Radix not implemented: {other}"),
}
// after
match radix {
2 | 8 | 10 | 16 => c.filter(|c| c.is_digit(radix)).is_some(),
other => unreachable!("radix {other} should have been rejected by the literal prefix parser"),
} Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
fn is_supported_radix(r: u32) -> bool { matches!(r, 2 | 8 | 10 | 16) } Try / catch
// Panics abort the lexer; guard the radix before calling is_digit_of_radix.
if !matches!(radix, 2 | 8 | 10 | 16) { return Err(LexicalError::UnsupportedRadix(radix)); } Prevention
- Pass radices only from the fixed set tied to literal prefixes (0b/0o/0x/decimal).
- Prefer returning a lexical error over panicking when adding new literal forms.
- Run lexer fuzz tests when touching numeric literal handling.
When it happens
Trigger: Calling `is_digit_of_radix(c, radix)` with any `radix` other than 2, 8, 10, or 16 while lexing a numeric literal (e.g. a new literal prefix wired with radix 3 or 0).
Common situations: Hit by lexer contributors experimenting with new number literal syntax, or by fuzzers mutating radix arguments. End users cannot choose the radix, so normal compilation never triggers it.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of gleam-lang/gleam@49f8762da5 (2026-09-14).
Data as JSON: /api/errors/24b269ed31489fec.
Report an issue: GitHub.
Appendix: source
Thrown at compiler-core/src/parse/lexer.rs:1248
loop {
if Lexer::is_digit_of_radix(self.char0, radix) {
let _ = self.next_char().expect("radix_run digit");
} else if self.char0 == Some('_') && Lexer::is_digit_of_radix(self.char1, radix) {
let _ = self.next_char();
} else {
break;
}
}
&self.source[start..self.get_position() as usize]
}
// Test if a digit is of a certain radix.
fn is_digit_of_radix(c: Option<char>, radix: u32) -> bool {
match radix {
2 | 8 | 10 | 16 => c.filter(|c| c.is_digit(radix)).is_some(),
other => panic!("Radix not implemented: {other}"),
}
}
// There are 3 kinds of comments
// 2 slash, normal
// 3 slash, document
// 4 slash, module
// this function is entered after 2 slashes
fn lex_comment(&mut self) -> Spanned {
enum Kind {
Comment,
Doc,
ModuleDoc,
}
let kind = match (self.char0, self.char1) {
(Some('/'), Some('/')) => {
let _ = self.next_char();
let _ = self.next_char();View on GitHub (pinned to 49f8762da5)