Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle new eval source location #200

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## HEAD (unreleased)

- Handle Ruby 3.3 new eval source location format (https://github.com/ruby/syntax_suggest/pull/200).

## 1.1.0

- Handle if/else with comment or empty line in branch (https://github.com/ruby/syntax_suggest/pull/193)
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_suggest/pathname_from_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module SyntaxSuggest
# # => "/tmp/scratch.rb"
#
class PathnameFromMessage
EVAL_RE = /^\(eval\):\d+/
EVAL_RE = /^\(eval.*\):\d+/
STREAMING_RE = /^-:\d+/
attr_reader :name

Expand Down
2 changes: 1 addition & 1 deletion spec/integration/ruby_command_line_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Dog
out = `#{ruby} -I#{lib_dir} -rsyntax_suggest #{script} 2>&1`

expect($?.success?).to be_falsey
expect(out).to include("(eval):1")
expect(out).to match(/\(eval.*\):1/)

expect(out).to_not include("SyntaxSuggest")
expect(out).to_not include("Could not find filename")
Expand Down
9 changes: 9 additions & 0 deletions spec/unit/pathname_from_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ module SyntaxSuggest
expect(file).to be_falsey
end

it "does not output error message on syntax error inside of an (eval at __FILE__:__LINE__)" do
message = "(eval at #{__FILE__}:#{__LINE__}):1: invalid multibyte char (UTF-8) (SyntaxError)\n"
io = StringIO.new
file = PathnameFromMessage.new(message, io: io).call.name

expect(io.string).to eq("")
expect(file).to be_falsey
end

it "does not output error message on syntax error inside of streamed code" do
# An example of streamed code is: $ echo "def foo" | ruby
message = "-:1: syntax error, unexpected end-of-input\n"
Expand Down