ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:120179] [Ruby master Bug#20945] Behaviour mismatch between parse.y and prism with character literals AST nodes
@ 2024-12-11 16:25 viralpraxis (Iaroslav Kurbatov) via ruby-core
  2024-12-11 16:53 ` [ruby-core:120180] " ufuk (Ufuk Kayserilioglu) via ruby-core
  2024-12-11 17:00 ` [ruby-core:120181] " viralpraxis (Iaroslav Kurbatov) via ruby-core
  0 siblings, 2 replies; 3+ messages in thread
From: viralpraxis (Iaroslav Kurbatov) via ruby-core @ 2024-12-11 16:25 UTC (permalink / raw)
  To: ruby-core; +Cc: viralpraxis (Iaroslav Kurbatov)

Issue #20945 has been reported by viralpraxis (Iaroslav Kurbatov).

----------------------------------------
Bug #20945: Behaviour mismatch between parse.y and prism with character literals AST nodes
https://bugs.ruby-lang.org/issues/20945

* Author: viralpraxis (Iaroslav Kurbatov)
* Status: Open
* ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------

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


``` ruby
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.



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:120180] [Ruby master Bug#20945] Behaviour mismatch between parse.y and prism with character literals AST nodes
  2024-12-11 16:25 [ruby-core:120179] [Ruby master Bug#20945] Behaviour mismatch between parse.y and prism with character literals AST nodes viralpraxis (Iaroslav Kurbatov) via ruby-core
@ 2024-12-11 16:53 ` ufuk (Ufuk Kayserilioglu) via ruby-core
  2024-12-11 17:00 ` [ruby-core:120181] " viralpraxis (Iaroslav Kurbatov) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: ufuk (Ufuk Kayserilioglu) via ruby-core @ 2024-12-11 16:53 UTC (permalink / raw)
  To: ruby-core; +Cc: ufuk (Ufuk Kayserilioglu)

Issue #20945 has been updated by ufuk (Ufuk Kayserilioglu).


`Parser::CurrentRuby` is coming from the [parser gem](https://github.com/whitequark/parser), and has nothing to do with parse.y, it is 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.

----------------------------------------
Bug #20945: Behaviour mismatch between parse.y and prism with character literals AST nodes
https://bugs.ruby-lang.org/issues/20945#change-110939

* Author: viralpraxis (Iaroslav Kurbatov)
* Status: Open
* ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------

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


``` ruby
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.



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [ruby-core:120181] [Ruby master Bug#20945] Behaviour mismatch between parse.y and prism with character literals AST nodes
  2024-12-11 16:25 [ruby-core:120179] [Ruby master Bug#20945] Behaviour mismatch between parse.y and prism with character literals AST nodes viralpraxis (Iaroslav Kurbatov) via ruby-core
  2024-12-11 16:53 ` [ruby-core:120180] " ufuk (Ufuk Kayserilioglu) via ruby-core
@ 2024-12-11 17:00 ` viralpraxis (Iaroslav Kurbatov) via ruby-core
  1 sibling, 0 replies; 3+ messages in thread
From: viralpraxis (Iaroslav Kurbatov) via ruby-core @ 2024-12-11 17:00 UTC (permalink / raw)
  To: ruby-core; +Cc: viralpraxis (Iaroslav Kurbatov)

Issue #20945 has been updated by viralpraxis (Iaroslav Kurbatov).


ufuk (Ufuk Kayserilioglu) wrote in #note-1:
> `Parser::CurrentRuby` is coming from the [parser gem](https://github.com/whitequark/parser), 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.

----------------------------------------
Bug #20945: Behaviour mismatch between parse.y and prism with character literals AST nodes
https://bugs.ruby-lang.org/issues/20945#change-110940

* Author: viralpraxis (Iaroslav Kurbatov)
* Status: Open
* ruby -v: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]
* Backport: 3.1: UNKNOWN, 3.2: UNKNOWN, 3.3: UNKNOWN
----------------------------------------

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


``` ruby
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.



-- 
https://bugs.ruby-lang.org/
 ______________________________________________
 ruby-core mailing list -- ruby-core@ml.ruby-lang.org
 To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
 ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-12-11 17:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-11 16:25 [ruby-core:120179] [Ruby master Bug#20945] Behaviour mismatch between parse.y and prism with character literals AST nodes viralpraxis (Iaroslav Kurbatov) via ruby-core
2024-12-11 16:53 ` [ruby-core:120180] " ufuk (Ufuk Kayserilioglu) via ruby-core
2024-12-11 17:00 ` [ruby-core:120181] " viralpraxis (Iaroslav Kurbatov) via ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).