diff --git a/crates/ruff_python_parser/src/lexer.rs b/crates/ruff_python_parser/src/lexer.rs index 167250179d..7d736d5ba7 100644 --- a/crates/ruff_python_parser/src/lexer.rs +++ b/crates/ruff_python_parser/src/lexer.rs @@ -1716,4 +1716,22 @@ def f(arg=%timeit a = b): let source = "[1"; let _ = lex(source, Mode::Module).collect::>(); } + + /// Emoji identifiers are a non-standard python feature and are not supported by our lexer. + #[test] + fn test_emoji_identifier() { + let source = "🐦"; + + let lexed: Vec<_> = lex(source, Mode::Module).collect(); + + match lexed.as_slice() { + [Err(error)] => { + assert_eq!( + error.error, + LexicalErrorType::UnrecognizedToken { tok: '🐦' } + ); + } + result => panic!("Expected an error token but found {result:?}"), + } + } }