Skip to content

(#17260) Issue warning for hypens in variables#1243

Merged
zaphod42 merged 3 commits intopuppetlabs:2.7.xfrom
zaphod42:feature/2.7.x/17260-deprecation-warning-for-hyphens-in-variables
Oct 30, 2012
Merged

(#17260) Issue warning for hypens in variables#1243
zaphod42 merged 3 commits intopuppetlabs:2.7.xfrom
zaphod42:feature/2.7.x/17260-deprecation-warning-for-hyphens-in-variables

Conversation

@zaphod42
Copy link
Contributor

In commit b26699a, daniel-pittman fixed an accidentally introduced change to
the lexer, allowing - to be part of a variable name. That had lasted for a
while and was surprisingly popular. It was also hugely ambiguous around - as
minus, and led to all sorts of failures - unexpected interpolations to nothing

  • because of that.

This adds the ability to turn hypens back on in the lexer, but issues a
deprecation warning when they are used. By default hyphens are still turned
off.

Puppet 3 should not have this feature and so this change must not be merged
into the 3.0.x or master branches.

Daniel Pittman and others added 3 commits October 29, 2012 16:01
In commit b26699a I fixed an accidentally introduced change to the lexer,
allowing `-` to be part of a variable name.  That had lasted for a while and
was surprisingly popular.  It was also hugely ambiguous around `-` as minus,
and led to all sorts of failures - unexpected interpolations to nothing -
because of that.

A much better strategy would have been to deprecate the feature, issue proper
warnings, and include an option to allow users to toggle the behaviour.

Initially defaulting that to "permit", and eventually toggling over to "deny",
would have made the whole experience much smoother - even if this was totally
documented as not working, and was a clear bug that it changed.

So, thanks to prompting from Benjamin Irizarry, we do just that: introduce the
configuration option, default it to "deny" to match current behaviour, but
allow users the choice to change this back.

Please be aware that allowing variables with `-` might break all sorts of
things around, for example, Forge modules though.  Most people write code to
the documented standard, and their code might well totally fail to work with
this changed away from the default!

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
This commit shortens and tightens the description of this setting.
Previously the deprecation warnings for hyphens in variables
incorrectly warned even when there were no hyphens in the variable.
There was also no warning about hypens in variable interpolations when
the bare-word form of interpolation was used, e.g. "${foo-bar}".

This commit causes those two cases to warn correctly and also cleans up
the tests to be more directed to just the lexing of specific tokens.
This also removes some duplication that crept in around checking and
issuing the warning.

Paired-with: henrik.lindberg@cloudsmith.com
@zaphod42
Copy link
Contributor Author

I'm going to merge this now, as @haus informed me, rightly, that if I don't do it now we won't get our acceptance tests run against this by the time we want it to go out later tomorrow.

zaphod42 added a commit that referenced this pull request Oct 30, 2012
…n-warning-for-hyphens-in-variables

(#17260) Issue warning for hypens in variables
@zaphod42 zaphod42 merged commit cf0bfc1 into puppetlabs:2.7.x Oct 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants