Project

General

Profile

Actions

Bug #15535

closed

Optional arguments for definition - Syntax Error is not the correct Error type

Bug #15535: Optional arguments for definition - Syntax Error is not the correct Error type

Added by waheedi (Waheed Barghouthi) almost 7 years ago. Updated almost 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:91088]

Description

The below definition throws a Syntax Error, while there is no syntax error and I'm not sure what is the intention behind the Syntax Error

def hello(foo="bar", bar, yanko="me")
  p "Hello"
end

The same definition below with a tiny modification in the argument set, give a Syntax OK.

def hello(foo="bar", bar="foo", yanko="me")
  p "Hello"
end

It seems when there is a required argument in the definition that happens to be in between optional arguments that triggers a Syntax Error, I think the ArgumentError is more related to it.

This has been tested on mostly every ruby version after 1.8.7 and it gave the same result.

Updated by waheedi (Waheed Barghouthi) almost 7 years ago Actions #1

  • ruby -v changed from 2.6.0p0 to 2.6.0

Updated by waheedi (Waheed Barghouthi) almost 7 years ago Actions #2

  • ruby -v changed from 2.6.0 to 2.6.0p0

Updated by waheedi (Waheed Barghouthi) almost 7 years ago Actions #3

  • Description updated (diff)

Updated by waheedi (Waheed Barghouthi) almost 7 years ago Actions #4

  • Description updated (diff)

Updated by nobu (Nobuyoshi Nakada) almost 7 years ago Actions #5 [ruby-core:91091]

  • Status changed from Open to Rejected

Required arguments cannot be placed between optional arguments syntactically, so it must be a SyntaxError.
ArgumentError is a runtime error.

Actions

Also available in: PDF Atom