ruby-next: Failed to transpile ./lib/syntax_tree/node.rb: SyntaxError — unexpected token tRBRACK
What did you do?
git clone https://github.com/kddnewton/syntax_tree.git
cd syntax_tree
git checkout cb72efc779aa8e9fdc812fc81b495c7998332f21
bundle
gem install ruby-next
ruby-next -V nextify ./lib
which shows:
RubyNext core strategy: refine
RubyNext transpile mode: rewrite
Remove old files: ./lib/.rbnext
Generated: ./lib/.rbnext/2.3/syntax_tree/basic_visitor.rb
Generated: ./lib/.rbnext/2.3/syntax_tree/cli.rb
Generated: ./lib/.rbnext/2.3/syntax_tree/formatter.rb
Generated: ./lib/.rbnext/2.7/syntax_tree/language_server/inlay_hints.rb
Generated: ./lib/.rbnext/2.7/syntax_tree/language_server.rb
Failed to transpile ./lib/syntax_tree/node.rb: SyntaxError — unexpected token tRBRACK
Additional Context
https://github.com/ruby-syntax-tree/syntax_tree/issues/168
$ ruby -rparser/current -rbenchmark -e 'pp Parser::CurrentRuby.parse(File.read("./lib/syntax_tree/node.rb"))'
does work, so it seems parser can parse it.
Environment
Ruby version: I tried CRuby 3.0 and 3.1
Ruby Next version: 0.15.2
Parser version: 3.1.2.1
Unparser version: 0.6.5
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17
In general when using RubyNext in a gem I’d want to avoid the runtime dependency, hence I did the manual
$LOAD_PATH.unshift "#{__dir__}/.rbnext"above.@palkan yeah unfortunately
deconstruct_keyswas showing up quite a lot in the profile. Switching back to acase..whengave me some performance back.I think we can do a better job in CRuby of rewriting the iseqs to do some smarter matching when common patterns are found. Or just let YJIT do its thing. But in the meantime I decided to just roll with eliminating the pattern matching for now.