rbs
rbs copied to clipboard
`rbs prototype rb` generates wrong definitions for files including "#$"
rbs generates a definition that causes a syntax error if the file includes '#$'.
Steps to reproduce
$ cat foo.rb
class A
X = '#$'
end
$ rbs prototype rb foo.rb > foo.rbs
$ cat foo.rbs
class A
X: "\#$"
end
$ rbs parse foo.rbs
foo.rbs:2:5...2:6: Syntax error: unexpected token for simple type, token=`"` (ErrorToken)
System Information
$ ruby --version
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]
$ rbs --version
rbs 3.1.0
Notes
I report that the error did not occur in v2.5.1, but did occur in v2.6.0.
$ rbs _2.5.1_ parse foo.rbs
$ rbs _2.6.0_ parse foo.rbs
foo.rbs:2:5...2:6: Syntax error: unexpected token for simple type, token=`"` (ErrorToken)
#1316 will solve this problem by fixing RBS::Writer. But this PR doesn't change the behavior of the parser.