Bug #20945
closedBehaviour mismatch between parse.y and prism with character literals AST nodes
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.
Updated by ufuk (Ufuk Kayserilioglu) 11 days ago · Edited
Parser::CurrentRuby
is coming from the parser gem, and has nothing to do with parse.y, it is a pure Ruby implementation of a Ruby parser.
If you think the AST of Prism should behave differently, please open an issue on the https://github.com/ruby/prism repo itself.
Updated by viralpraxis (Iaroslav Kurbatov) 11 days ago
ufuk (Ufuk Kayserilioglu) wrote in #note-1:
Parser::CurrentRuby
is coming from the parser gem, and has nothing to do with parse.y, it is a pure Ruby implementation of a Ruby parser.If you think the AST of Prism should behave differently, please open an issue on the https://github.com/ruby/prism repo itself.
Got it, thanks!
We can close this issue then. Sorry for misunderstanding.
Updated by jeremyevans0 (Jeremy Evans) 11 days ago
- Status changed from Open to Rejected