ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: eregontp@gmail.com
To: ruby-core@ruby-lang.org
Subject: [ruby-core:101496] [Ruby master Bug#17398] SyntaxError in endless method
Date: Thu, 17 Dec 2020 13:52:26 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-89276.20201217135226.710@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17398.20201216195217.710@ruby-lang.org

Issue #17398 has been updated by Eregon (Benoit Daloze).


Conceptually, according to the typical definition in computer science, both `puts("bar")` and `puts "bar"` are expressions (i.e., they return a value, and if it was some other method than `puts` it would also not always be `nil`).
It might be slightly less clear for e.g. `a = 42` (it's still an expression, it still returns a value), but I think `puts "bar"` is clear that it should be the same as `puts("bar")`, except for precedence.

So it's probably going to be very difficult to explain the actual condition, other than showing specific examples.

----------------------------------------
Bug #17398: SyntaxError in endless method
https://bugs.ruby-lang.org/issues/17398#change-89276

* Author: zverok (Victor Shepelev)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
This works:
```ruby
def foo() = puts("bar")
```

This does not:
```ruby
def foo() = puts "bar"
#                ^ syntax error, unexpected string literal, expecting `do' or '{' or '('
```

Is this intentional or accidental? Not sure how it is reasoned.



-- 
https://bugs.ruby-lang.org/

  parent reply	other threads:[~2020-12-17 13:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 19:52 [ruby-core:101475] [Ruby master Bug#17398] SyntaxError in endless method zverok.offline
2020-12-17  0:49 ` [ruby-core:101482] " mame
2020-12-17  9:39 ` [ruby-core:101495] " zverok.offline
2020-12-17 13:52 ` eregontp [this message]
2020-12-17 16:16 ` [ruby-core:101498] " halostatue
2020-12-18  1:58 ` [ruby-core:101503] " mame
2021-04-16  4:30 ` [ruby-core:103470] [Ruby master Feature#17398] " matz
2021-04-19  5:06 ` [ruby-core:103510] " mame
2021-05-12  8:32 ` [ruby-core:103795] " matz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-89276.20201217135226.710@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).