Issue #21117 has been updated by Henrik Lindberg.

Status changed from Unreviewed to Needs Decision

In 3x parser=current, this is close to impossible to fix - the syntax error is 
raised because the parser cannot make sense of the expression (the rule for 
keys simply does nmot include the "QualifiedReference").

The 3x parser=future can be made to generate a better error.

However, going forward (new evaluator) we may want to use more advanced keys in 
hashes - not just strings. In which case the example is valid, but the key 
would be a Type, not a String thus:

    $hash[Wat] != $hash['Wat']

We could also restrict the keys in a hash to always be literals, and also 
accept QualifiedReference as a string.

The most powerful is naturally to allow any expression - a hash can be written 
like this (if we want to):

    $hash = { if $x == 10 { 'a string key' } else { Integer } => 'the data' }
 
The decision to make is if hashes should be capable of having more advanced 
keys than string/number, and if other expressions (e.g. QualifiedReference)   
is then either an error, or is boxed to a String.

----------------------------------------
Feature #21117: Improve error message for illegal hash keys
https://projects.puppetlabs.com/issues/21117#change-97436

* Author: Charlie Sharpsteen
* Status: Needs Decision
* Priority: Normal
* Assignee: Henrik Lindberg
* Category: parser
* Target version: 
* Affected Puppet version: 3.2.1
* Keywords: 
* Branch: 
----------------------------------------
Currently using an illegal hash key, such as a resource reference, results in a 
rather cryptic error message:

<pre>
puppet apply -e '$my_var = {Some_thing => "hai"}'
Error: Could not parse for environment production: Syntax error at 
'Some_thing'; expected '}' at line 1 on node puppetmaster.boxnet
Error: Could not parse for environment production: Syntax error at 
'Some_thing'; expected '}' at line 1 on node puppetmaster.boxnet
</pre>

As discussed in #14704, this could be dramatically improved to something like 
"Illegal hash key – a QualifiedReference is not a valid hash key".


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to