Project

General

Profile

Actions

Bug #15467

closed

Creating a class with a Cyrillic first symbol in the name leads to a SyntaxError in IRB

Added by an_vlad (Vladislav Andreev) over 5 years ago. Updated almost 5 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
[ruby-core:90732]

Description

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:

  1. Run IRB.
  2. Write: class Класс and hit 'Enter'.

This leads to a syntax error: unexpected end-of-input, expecting end.

Some details:

  • class Класс; end will 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 Hanmac (Hans Mackowiak) over 5 years ago

from #13770 it should work? can you try it in pure ruby if your class name works?

i think the problem might be more in irb than ruby itself?

Updated by shevegen (Robert A. Heiler) over 5 years ago

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?

Updated by an_vlad (Vladislav Andreev) over 5 years 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) over 5 years ago

  • Assignee set to keiju (Keiju Ishitsuka)

It is indeed the first letter that's relevant. Examples such as
class Sigmα
(last letter of class name is Greek alpha) and
class Sιγμα
(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) almost 5 years 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)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0