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

optparse duplication #2307

Closed
Tracked by #2254
kddnewton opened this issue Jan 30, 2024 · 4 comments · Fixed by ruby/ruby#9783
Closed
Tracked by #2254

optparse duplication #2307

kddnewton opened this issue Jan 30, 2024 · 4 comments · Fixed by ruby/ruby#9783
Assignees
Labels
bug Something isn't working compiler
Milestone

Comments

@kddnewton
Copy link
Collaborator

kddnewton commented Jan 30, 2024

require "optparse"

opt = OptionParser.new
opt.def_option(/^[^-]/) {}

begin
  opt.parse(["-t"])
rescue OptionParser::InvalidOption
  p $!.args
end
@kddnewton kddnewton changed the title - something duplicate, maybe encoding related, fixes a bunch optparse duplication Jan 30, 2024
@kddnewton kddnewton added bug Something isn't working compiler labels Jan 30, 2024
@kddnewton kddnewton added this to the Ruby 3.3.1 milestone Jan 30, 2024
@peterzhu2118 peterzhu2118 self-assigned this Jan 30, 2024
@peterzhu2118
Copy link
Member

I'm not sure what the issue here is. Both Ruby and prism outputs ["-t"] for me.

@kddnewton
Copy link
Collaborator Author

@peterzhu2118 really? Ruby outputs ["-t"] for me and prism outputs ["-t", "-t"]

@peterzhu2118
Copy link
Member

This works for me on ruby/ruby@731367d0ab.

@peterzhu2118
Copy link
Member

I found a minimum repro:

calls = []
begin
  begin
  rescue RuntimeError
    calls << 1
  else
    calls << 2
    raise RuntimeError
  end
rescue RuntimeError
end

calls

It should output [2] but outputs [2, 1].

peterzhu2118 added a commit to peterzhu2118/ruby that referenced this issue Jan 31, 2024
kddnewton pushed a commit to ruby/ruby that referenced this issue Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants