From: "hurricup (Alexandr Evstigneev) via ruby-core" Date: 2023-04-06T06:43:24+00:00 Subject: [ruby-core:113147] [Ruby master Bug#19583] Unary minus inconsistency when used with variables and literals Issue #19583 has been reported by hurricup (Alexandr Evstigneev). ---------------------------------------- Bug #19583: Unary minus inconsistency when used with variables and literals https://bugs.ruby-lang.org/issues/19583 * Author: hurricup (Alexandr Evstigneev) * Status: Open * Priority: Normal * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN, 3.2: UNKNOWN ---------------------------------------- This feels a bit inconsistent and I could not find an explanation. This is fine and `-` has higher precedence than `.` ``` -2.upto 0 do |arg| puts arg end ``` But this is not working, won't even compile (requires parens): ``` var = 2 -var.upto 0 do |arg| puts arg end ``` I presume that in the first example there is no unary minus operation, just negative literal. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/