Project

General

Profile

Actions

Bug #20216

open

Circular parameter reference not checked for assignment

Added by kddnewton (Kevin Newton) about 1 month ago. Updated about 1 month ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:116458]

Description

I wanted to check if this was a bug or desired.

Usually when you reference a parameter within its own default value (optional positional or optional keyword) it raises a syntax error. This is unless you use it in an assignment, in which case it is not checked. Is this desired? Here's an example:

def foo(bar = bar = 1); end
def foo(bar: bar = 1); end

I'm not sure what this code is supposed to be doing. I expected it to raise a syntax error.

Updated by nobu (Nobuyoshi Nakada) about 1 month ago

They are not "reference"s, I think.

Actions

Also available in: Atom PDF

Like0
Like0