Creating a class with a Cyrillic first symbol in the name leads to a SyntaxError in IRB
What happens: a syntax error occurs when a user writes
class Класс and hits 'Enter' in IRB.
What is expected to happen: the same thing that happens when you create a class in IRB with
class SomeClass line and hit 'Enter'.
How to reproduce:
- Run IRB.
class Классand hit 'Enter'.
This leads to a syntax error:
unexpected end-of-input, expecting end.
class Класс; endwill successfully create a class.
- It seems like having a Cyrillic symbol as the first letter in a class name causes this error:
class ZКлассworks fine.
Updated by an_vlad (Vladislav Andreev) 10 months ago
shevegen (Robert A. Heiler) wrote:
Interesting that the first variant with "; end" works.
Does the code work for you in every way when you put it into a standalone .rb file and run this?
Yes, it does work when I run similar code in a file.
UPD I've just tried to run the same piece of code with a Greek name (
class Κατηγορίας and then 'Enter') and it also didn't work inside the IRB session. So this issue is caused by any Unicode symbol taking the first place in the name of a class.
Updated by duerst (Martin Dürst) 10 months ago
- Assignee set to keiju (Keiju Ishitsuka)
It is indeed the first letter that's relevant. Examples such as
(last letter of class name is Greek alpha) and
(only first letter is Latin, rest is Greek) work without problems.
The problem for me is that the traceback doesn't give any specific information.
I have assigned this issue to Keiju Ishitsuka, the creator of IRB. Hopefully we can get some help or hints from him.
Updated by jeremyevans0 (Jeremy Evans) 4 months ago
- Status changed from Open to Closed
This issue was fixed before 2.7.0-preview1:
$ irb27 irb(main):001:0> class Класс irb(main):001:0> end => nil irb(main):002:0> class ласс irb(main):002:0> end Traceback (most recent call last): 3: from /usr/local/bin/irb27:23:in `<main>' 2: from /usr/local/bin/irb27:23:in `load' 1: from /usr/local/lib/ruby/gems/2.7/gems/irb-1.0.0/exe/irb:11:in `<top (required)>' SyntaxError ((irb):2: class/module name must be CONSTANT) class ласс ^~~~~~~~ $ irb26 irb(main):001:0> class Класс Traceback (most recent call last): 3: from /usr/local/bin/irb26:23:in `<main>' 2: from /usr/local/bin/irb26:23:in `load' 1: from /usr/local/lib/ruby/gems/2.6/gems/irb-1.0.0/exe/irb:11:in `<top (required)>' SyntaxError ((irb):1: syntax error, unexpected end-of-input, expecting end)