Bug #14627
closed
class_eval "def foo(N:)\n end" regression
Added by ViugiNick (Nickolay Viuginov) over 6 years ago.
Updated over 6 years ago.
Description
Ruby crashes with a segfault in case of class_eval
defining method with a keyword starts with a capital letter. It seems like it's a regression of one of the latest versions.
Files
I can't reproduce it.
$ ruby -v -e 'Class.new.class_eval "def foo(N:)\n end"'
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux-gnu]
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `class_eval': (eval):1: formal argument cannot be a constant (SyntaxError)
def foo(N:)
^~
(eval):1: dynamic constant assignment
def foo(N:)
^
Could you post simple code to reproduce and full message, in text format?
- Status changed from Open to Feedback
I could repro:
$ ruby -e 'Class.new.class_eval "def f(a:, N:)\nend"'
-e:1: [BUG] Segmentation fault at 0x0000000000000028
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
*snip*
This [BUG] does not occur on trunk, so maybe it has been already fixed.
I cannot reproduce it on the HEAD of ruby_2_5:
$ ruby -ve 'Class.new.class_eval "def foo(a:, N:)\nend"'
ruby 2.5.1p53 (2018-03-25 revision 62911) [x86_64-darwin16]
Traceback (most recent call last):
1: from -e:1:in `<main>'
-e:1:in `class_eval': (eval):1: formal argument cannot be a constant (SyntaxError)
def foo(a:, N:)
^~
(eval):1: dynamic constant assignment
def foo(a:, N:)
^
- Is duplicate of Bug #14261: invalid syntax segfaults: "x, true" added
- Status changed from Feedback to Closed
- Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: DONTNEED, 2.4: DONTNEED, 2.5: DONTNEED
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0