Project

General

Profile

Actions

Bug #15956

closed

`{*nil}` causes confusing error message

Added by Tietew (Toru Iwase) almost 3 years ago. Updated almost 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.0dev (2019-06-24T15:19:49Z trunk e09afd15b7) [x86_64-linux]
[ruby-core:93353]

Description

$ ruby -e 'p({*nil})'
-e:1: syntax error, unexpected *, expecting '}'
p({*nil})
-e:1: Can't assign to nil
p({*nil})

First syntax error is intended.
But second error message Can't assign to nil is confusing.

This happens with nil, true, false and self.
Other identifiers including keywords don't.


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Bug #15078: Hash splat of empty hash should not create a positional argument.Closedmatz (Yukihiro Matsumoto)Actions
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 3 years ago

  • Is duplicate of Bug #15078: Hash splat of empty hash should not create a positional argument. added
Actions #2

Updated by jeremyevans0 (Jeremy Evans) almost 3 years ago

  • Status changed from Open to Closed

Fixed by #14183:

$ ruby -e 'def foo(*args); p args; end; foo(**{}); foo(**Hash.new) '
[]
[]
Actions

Also available in: Atom PDF