You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For blocks, source_location reports the line where the block opens as its line number. If the block is part of a multiline expression, this can be partway through the expression.
Maybe expression_at needs to start looking backwards (at line numbers prior to the provided one) if the first line has a syntax error?
classAattr_reader:blkdefinitialize(_stuff, &blk)@blk=blkendenda=A.new("a"=>1,"b"=>2)do"Block!"endb=A.new("a"=>1,"b"=>2)do# line 14"Block!"endputsa.blk.source#=> worksputsb.blk.source_location#=> a.rb 14putsb.blk.source#=> MethodSource::SourceNotFoundError
MethodSource::SourceNotFoundError: Could not parse source for #<Proc:0x00007f85ebcb34a0 ~/a.rb:14>: (eval):2: syntax error, unexpected =>, expecting end-of-input
"b" => 2) do
^~
from ~/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/method_source-1.0.0/lib/method_source.rb:29:in `rescue in source_helper'
Caused by SyntaxError: (eval):2: syntax error, unexpected =>, expecting end-of-input
"b" => 2) do
^~
from ~/.rbenv/versions/2.7.3/lib/ruby/gems/2.7.0/gems/method_source-1.0.0/lib/method_source/code_helpers.rb:71:in `eval'
The text was updated successfully, but these errors were encountered:
ccutrer
added a commit
to ccutrer/method_source
that referenced
this issue
Jul 11, 2022
Related to #22
For blocks,
source_location
reports the line where the block opens as its line number. If the block is part of a multiline expression, this can be partway through the expression.Maybe
expression_at
needs to start looking backwards (at line numbers prior to the provided one) if the first line has a syntax error?The text was updated successfully, but these errors were encountered: