Jira (PUP-4887) Reserved words as hash keys?
Title: Message Title Henrik Lindberg commented on PUP-4887 Re: Reserved words as hash keys? It is not a bug. You cannot use bare word keywords as hash-keys since they can be any _expression_. If you want a keyword use a quoted string. $hsh = { 'if' = 'the pope has a funny hat' } This because you can write: $funny_hat_people = [pope, santa, 'steve martin', 'the grinch'] $person = 'pope' $hsh = { if $person in $funny_hat_people { 'funny' } else {'not funny'} = true } Add Comment This message was sent by Atlassian JIRA (v6.4.5#64020-sha1:78acd6c)
Jira (PUP-4887) Reserved words as hash keys?
Title: Message Title Henrik Lindberg commented on PUP-4887 Re: Reserved words as hash keys? Note that keywords are allowed as attribute names in classes and defines as well as in variable names: class why_oh_why($if = 'reason') { # ... } class { why_oh_why: if = 'just because' } Add Comment This message was sent by Atlassian JIRA (v6.4.5#64020-sha1:78acd6c)
Jira (PUP-4887) Reserved words as hash keys?
Title: Message Title Alexander Fisher created an issue Puppet / PUP-4887 Reserved words as hash keys? Issue Type: Bug Assignee: Unassigned Created: 2015/07/16 7:09 AM Priority: Minor Reporter: Alexander Fisher Hi Should it be possible to declare a hash which has a reserved word as a key? eg $myhash = { key1 = 'val1', type = 'val2' } With this code and the future parser you get a parse error. Error: Could not parse for environment production: Use of reserved word: type, must be quoted if intended to be a String value The opinion on IRC was that this may be a bug and was worth reporting. Alternatively, perhaps just the documentation needs a note? Kind Regards, Alex