Expected behavior and actual behavior of Rightg assignment. see: https://bugs.ruby-lang.org/issues/15921
p RUBY_VERSION # => "2.8.0"
p RUBY_DESCRIPTION # => "ruby 2.8.0dev (2020-05-13T06:47:51Z master 87662134b5) [x86_64-linux]"
42 => value
# Expected behavior: value = 42
# Actual behavior : value = 42
42 => value1 => value2
# Expected behavior: value2 = value1 = 42
# Actual behavior : value2 = value1 = 42
42 => value1 = value2 => value3
# Expected behavior: value3 = value1 = value2 = 42
# Actual behavior : syntax error
value1, value2 = 42 => value3
# Expected behavior: ???
# Actual behavior : syntax error
a + b => c + b
# Expected behavior: c + b = a + b
# Actual behavior : syntax error
42 => value[:key]
# Expected behavior: value[:key] = 42
# Actual behavior : value[:key] = 42
42 => obj.value
# Expected behavior: obj.value = 42 # call `obj.value=`
# Actual behavior : obj.value = 42
{ key => 42 } => value
# Expected behavior: value = { :key => 42 }
# Actual behavior : value = { :key => 42 }
[1, 2] => a, b
# Expected behavior: a, b = [1, 2]
# Actual behavior : a, b = [1, 2]
*[1, 2] => a, b
# Expected behavior: a, b = *[1, 2]
# Actual behavior : syntax error
[1, 2, 3, 4, 5] => a, b, *c
# Expected behavior: a, b, *c = [1, 2, 3, 4, 6]
# Actual behavior : a, b, *c = [1, 2, 3, 4, 6]
[1, 2, 3, 4, 5] => a, b, *
# Expected behavior: a, b, * = [1, 2, 3, 4, 6]
# Actual behavior :
# If end of line is `*`, include up to the next line
# [1, 2, 3, 4, 5] => a, b, *
# c
#
# ↓
#
# [1, 2, 3, 4, 5] => a, b, *c
1 + 2 => value
# Expected behavior: value = 1 + 2
# Actual behavior : value = 1 + 2
a == b => value
# Expected behavior: value = a == b
# Actual behavior : value = a == b
-> {} => value
# Expected behavior: value = -> {}
# Actual behavior : value = -> {}
a || b => value
# Expected behavior: a || value = b
# Actual behavior : value = (a || b)
1 +=> a
# Expected behavior: a += 1
# Actual behavior : syntax error
42 ||=> @a
# Expected behavior: @a ||= 42
# Actual behavior : syntax error
func => value
# Expected behavior: value = func
# Actual behavior : value = func
func 42 => value
# Expected behavior: value = func(42) or func(value = 42) or func({ 42 => value })
# Actual behavior : func({ 42 => value })
func(42) => value
# Expected behavior: value = func(42)
# Actual behavior : value = func(42)
(func 42) => value
# Expected behavior: value = (func 42)
# Actual behavior : value = (func 42)
func(42 => value)
# Expected behavior: func(value = 42) or func({ 42 => value })
# Actual behavior : func({ value = 42 })
func 42 => value1 => value2
# Expected behavior: value2 = value1 = func(42) or func(value1 = value2 = 42) or func({ 42 => value1}) => value2
# Actual behavior : syntax error
func a => value, b
# Expected behavior: value, b = func(a) or func(value = a, b)
# Actual behavior : syntax error
func(a => value, b)
# Expected behavior: func(value = a, b)
# Actual behavior : syntax error
func a => value, b => value2
# Expected behavior: value2 = value, b = func(a) or func(value = a, value2 = b) or func({ a => value, b => value2 })
# Actual behavior : func({ a => value, b => value2 })
func(a => value, b => value2)
# Expected behavior: func(value = a, value2 = b) or func({ a => value, b => value2 })
# Actual behavior : func({ a => value, b => value2 })
func(a => value, b) => value2 #
# Expected behavior: value2 = func(value = a, b)
# Actual behavior : syntax error
func[42 => value]
# Expected behavior: func[value = 42]
# Actual behavior : func[{ 42 => value }]
func [42 => value]
# Expected behavior: func [value = 42]
# Actual behavior : func [{ 42 => value }]
func(42) {} => value
# Expected behavior: value = func(42) {}
# Actual behavior : value = func(42) {}
func do end => value
# Expected behavior: value = func do end
# Actual behavior : value = func do end
func 42 do end => value
# Expected behavior: value = func(42) do end
# Actual behavior : syntax error
cond ? a : b => value
# Expected behavior: value = cond ? a : b
# Actual behavior : value = cond ? a : b
cond ? a : (b => value)
# Expected behavior: cond ? a : (value = 2)
# Actual behavior : cond ? a : (value = 2)
(cond ? a : b) => value # value = cond ? a : b
# Expected behavior: (cond ? a : b) => value
# Actual behavior : (cond ? a : b) => value
cond ? a => value : b
# Expected behavior: cond ? (a => value) : b or syntax error
# Actual behavior : syntax error
cond ? a => value : b => value2
# Expected behavior: cond ? value = a : value2 = b or value2 = cond ? a => value : b or syntax error
# Actual behavior : syntax error
func cond ? a : b => value
# Expected behavior: value = func(cond ? a : b) or func({ (cond ? a : b) => value })
# Actual behavior : func({ (cond ? a : b) => value })
if cond => value; end
# Expected behavior: if value = cond; end
# Actual behavior : syntax error
if cond; end => value
# Expected behavior: value = if cond; end
# Actual behavior : value = if cond; end
42 => value if cond
# Expected behavior: value = 42 if cond
# Actual behavior : value = 42 if cond
for i in [1, 2, 3] => value; end
# Expected behavior: for i in value = [1, 2, 3]; end
# Actual behavior : syntax error
while cond => value; end
# Expected behavior: while value = cond; end
# Actual behavior : syntax error
def func(42 => value); end
# Expected behavior: def func(42 => value); end
# Actual behavior : syntax error
case expr; when :a; a; when :b; a; end => value
# Expected behavior: value = case expr; when :a; a; when :b; a; end
# Actual behavior : value = case expr; when :a; a; when :b; a; end
-> (42 => value) {}
# Expected behavior: -> (value = 42) {}
# Actual behavior : syntax error
-> 42 => value {} => value2
# Expected behavior: value2 = -> (value = 42) {}
# Actual behavior : syntax error