Skip to content

xml: fix incorrect use of rescue #27

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

Merged
merged 1 commit into from
Mar 31, 2025

Conversation

daipom
Copy link
Contributor

@daipom daipom commented Feb 13, 2025

To surely execute return, we need brackets.
Existing implementations try to perform useless processing without return when an exception occurs.

To surely execute `return`, we need brackets.
Existing implementations try to perform useless processing
without return when an exception occurs.

Signed-off-by: Daijiro Fukuda <[email protected]>
@daipom daipom requested review from kenhys and Watson1978 March 31, 2025 01:46
@Watson1978
Copy link

I confirmed the YARV instruction with following 3 cases.

  • 1
ruby --dump=insns -e "def hoge; return self.bar rescue nil; end"
  • 2
ruby --dump=insns -e "def hoge; (return self.bar) rescue nil; end"
  • 3
ruby --dump=insns -e "def hoge; return (self.bar rescue nil); end"

Then, I found 1 and 2 are same.

Here is more example.

def hoge
  if true
    return self.bar rescue nil # This should return nil as expected. However, it it not
  end

  return "hogehoge"
end

p hoge #=> hogehoge

Copy link

@Watson1978 Watson1978 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

@daipom daipom merged commit 3c1a3f1 into fluent:master Mar 31, 2025
20 checks passed
@daipom
Copy link
Contributor Author

daipom commented Mar 31, 2025

Thanks!

@daipom daipom deleted the xml-fix-incorrect-use-of-rescue branch April 10, 2025 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants