Project

General

Profile

Actions

Bug #20945

closed

Behaviour mismatch between parse.y and prism with character literals AST nodes

Added by viralpraxis (Iaroslav Kurbatov) 11 days ago. Updated 11 days ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]
[ruby-core:120179]

Description

AST string node (character literals) values returned by parse.y are, for some reason, frozen, whereas Prism does not freeze them:

require 'prism'
require 'parser/current'

puts Prism::VERSION
puts Parser::VERSION

p Prism.parse('?a').value.statements.child_nodes.first.content.then { [_1.class, _1.frozen?] }
p Parser::CurrentRuby.parse('?a').children[0].then { [_1.class, _1.frozen? ]}

p Prism.parse('?\n').value.statements.child_nodes.first.content.then { [_1.class, _1.frozen?] }
p Parser::CurrentRuby.parse('?\n').children[0].then { [_1.class, _1.frozen? ]}

output:

1.2.0
3.3.6.0
[String, false]
[String, false]
[String, false]
[String, true]

I’m not sure whether this is a bug in Parser, Prism, or something else.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0