Project

General

Profile

Actions

Bug #15932

closed

wrong "void value expression" error for 'next' or 'break' statements inside an 'if' assignment

Added by cvss (Kirill Vechera) almost 5 years ago. Updated about 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
1.8.7, 2.7.0preview1
[ruby-core:93199]

Description

When a 'next' or 'break' statement for block/loop control is placed inside an 'if' assignment, the parser outputs an error "void value expression". The same parsing error raises for the ternary operator in the same conditions.

I think, the the correct behavior should be consistent with the behavior of the 'case' statement, that is parsing such a code without errors and leaving the right-side variable with 'nil' value.

Examples of code giving a "void value expression" error:

begin
	a = if false
		'A'
	else
		next
	end
end while false
begin
	a = false ? 'A' : next
end while false

Example of code running without errors:

begin
	a = case false
		when true
			'A'
		else
			next
		end
end while false
begin
	a = (false or next)
end while false

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #11143: it should always be possible to return from an ifClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0