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

[Bug #19392] Make args connected with and/or as a body of method #8054

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

yui-knk
Copy link
Contributor

@yui-knk yui-knk commented Jul 10, 2023

def test = puts("foo") or puts("bar") is interrupted as def test = (puts("foo") or puts("bar")).

[Note] (2023-12-07) I created this patch to demonstrate it's not difficult to support this feature with LR parser generator. This doesn't mean I agree with the change.

`def test = puts("foo") or puts("bar")` is interrupted as
`def test = (puts("foo") or puts("bar"))`.
@zverok
Copy link
Contributor

zverok commented Nov 29, 2023

Unfortunately, this PR doesn't fix if/unless problem (which, despite my ticket's initial contents, is more critical than and/or):

def foo(arg) = p("OK") if arg

foo(false)
foo(true)

This is expected (with "natural" for the author precedences) to print "OK" once, but instead it fails with

test.rb:1:in `<main>': undefined local variable or method `arg' for main (NameError)

Apparently, it is still interpreted as

(def foo(arg) = p("OK")) if arg

Would it be possible to handle in the same manner? 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants