Skip to content

Commit 74ef259

Browse files
committed
fix(lexer): replace unimplemented! with syntax error for unknown operators
When the operator lexer encounters an unexpected byte, return Err(Error::syntax(...)) instead of panicking. Made-with: Cursor
1 parent c3fb70b commit 74ef259

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

core/parser/src/lexer/operator.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,15 @@ impl<R> Tokenizer<R> for Operator {
162162
b'~' => {
163163
Token::new_by_position_group(Punctuator::Neg.into(), start_pos, cursor.pos_group())
164164
}
165-
op => unimplemented!("operator {}", op),
165+
op => {
166+
return Err(Error::syntax(
167+
format!(
168+
"unexpected character '{}' in operator",
169+
char::from_u32(u32::from(op)).unwrap_or('\u{FFFD}')
170+
),
171+
start_pos.position(),
172+
));
173+
}
166174
})
167175
}
168176
}

0 commit comments

Comments
 (0)