Age | Commit message (Collapse) | Author | Files | Lines |
|
* pr/3136:
(PUP-3364) Improve the error message for numeric resource titles
|
|
This improves the error message when a numeric resource title is
used in a resource reference, or when a numeric attribute name is
referenced. The message used to be too generic, and used internal
Ruby types instead of puppet types in the message string.
|
|
This changes the mapping of arguments to 3x function calls to not
map undef to empty strings except at the surface level. Other mappings
are still done as they are required for frozen strings, and values
having a type that is not supported by the 3x functions.
|
|
Previously the future parser supported += and -=. += was very similar to
the same operator that is in the current parser, but with a few
differences to make it consistent with the rest of the
language. The += operator no longer performed string concatenation and
instead acted like $a = $a + $b. The -= operator was added to complete
the set of operators available.
However, many people have been confused by these operators (even as they
exist in the current parser):
* It looks like mutation, but the language does not have mutation
* It looks like += from other languages, but doesn't behave like them
* Shadowing a variable is something that needs to be explicit,
otherwise it becomes confusing.
This removes += and -= from the future parser. They are still parsed,
but the validation step will issue errors if they are encountered.
|
|
This changes the following:
* Assignment has lower precedence than resource expressions
* Local defaults are supported in resource instantiation expressions
* A Resource body may have a new expression AttributesOperation that
must evaluate to a hash.
* Stricter validation of resource titles
* Changes to TreeModelDumper wrt how BlockExpression is rendered (to
improve debugging output). As a consequence many tests needed
adjustments.
* Tests that previously passed have been modified because of stricter
validation.
This also includes maintenance. Removing dead code/fixing stale comments
and documentation.
|
|
This merges the behavior of the Transitional subclass of the
EvaluatingParser into the main class, as the hybrid solution is no
longer a supported alternative.
As a consequence, all references to the
Pops::Parser::EvaluatingParser::Transitional has been changed to
just Pops::Parser::EvaluatingParser.
This commit alters no behavior.
|
|
This removes all usage of Puppet[:evaluator] from the code base
since it is (in this version) enough to check if Puppet[:parser] is
'future' as the future evaluator is always used.
|
|
Changes the name of die_undef_die test assertion function to
assert_no_undef.
|
|
This changes the evaluation of a LiteralUndef to nil from :undef.
As a consequence, there were minor adjustments needed to the Closure's
call_by_name support to get the correct semantics for "missing"
parameters.
Tests are also added to ensure that :undef does not sneak into arrays or
hashes in the 4x function API.
This commit contains a cheat for epp and inline_epp functions as they
need to receive their arguments without transformation. When that is
fixed (PUP-2845) the cheat in runtime3_support#call_function() should be
removed.
:undef is still used in the "puppet/pops" section of the code (mainly
for reasons of transforming to 3x, and if :undef symbols leak from 3x.)
|
|
(PUP-1811) Make 'in' set match vars when regexp is used to match
|
|
hlindberg/PUP-2663_allow-unary-plus-minus-string-numeric-conversion
(PUP-2663) Allow unary plus/minus string numeric conversion
|
|
\s includes newline when ^$ is used.
^$ skips leading and trailing optional matches
\A\z does not skip as they force matching of strings start/end
|
|
|
|
|
|
This renames the top most type in the type system to Any from
the name Object. This is done because the word Object carries
connotations of "Object Oriented Programming" that simply adds confusion
about how puppet works.
This commit is basically a rename refactoring.
|
|
|
|
This adds tests that local and match scope handling is corrent
and does not leak variable bindings.
|
|
This moves all the iterative functions to the 4x function API.
Functions are now simpler to read. A shared utility module
was created for repeated asserts.
While testing it was clear that it is difficult to use
Puppet.lookup(:loaders), and the evaluator was changed to get the
loaders via the compiler instead.
The evaluator tests are changed to make use of the simplified
handling of the loaders.
The tests for the functions that have moved, were also moved, but
are unchanged in what they test.
|
|
Object is now the top class and so there is no need to use
Optional[Object] everywhere. This removes the type factory method
optional_object and replaces all occurrances with just object. It also
updates all of the uses of Optional[Object] to use just Object.
|
|
This improves testing of typed parameters, and the ivolved
tests in general. One test moved from being an evaluation test
(it only tested parsing).
Iterative function testing changed to use better matchers.
|
|
This makes define and class parameters support optionally typed
parameters when using the future parser. The type expressions
are evaluated by the Pops Bridge when parameters are transformed t 3x.
The 3x parameters are not aware of type information (they are encoded as
arrays), and changes to all the logic that deals with parameters turned
on to not be a good design. The resource type and resource is instead
made aware of the opt-in types via a separate param-name to type map
that it applies in the validation step that was already performed.
|
|
(PUP-2514) Remove ability to search for String type in String.
|
|
(PUP-1807) empty string is the truth
|
|
This makes it possible to use an unary +/- in a string. The sign
of the converted value abides by the unary string sign. White space is
allowed around the sign, and at the end of the string.
'+ 2' + '- 2' == 0
This is of value when dealing with original data in string form
that needs to be converted. Without this it is especially difficult to
pass a negative value around in string form.
|
|
While philosophically true, a String consists of a number of
substrings, it is not very meaningful to support only the ability to
assert that. In order to be useful it would need to answer a much wider
variety is Enum[red, blue, green] in "it was blue, orange, and red", is
there a String of 1-5 characters in length inside the string "1234" etc.
This commit removes the naive support for String/Data-type search
in String as it is more confusing than helpful. If we later find it to
be of value, a more elaborate implementation is needed.
|
|
This makes the selector expression in the future evaluator have
the same semantics as the 3.6.1 current evaluator. The future evauator
did not process default out of band, and did not raise an error when
there was no match.
This fixes both problems.
|
|
An empty string is now interpreted as a "true" value. It used to
represent a false value.
This representation is only in the future evaluator. Values are still
transformed when calling the 3x function API (it expect undef to be
encoded as empty string). This also takes place when transforming to the
3x catalog.
|
|
* upstream/stable:
(PUP-2568) Remove unnecessary calls
(maint) Reorder code to increase clarity
(PUP-2581) Make illegal names interchangeable to legal variable work
(PUP-2568) Downcase class name before validating
Conflicts:
lib/puppet/pops/parser/eparser.rb
Rebuilt eparser.
|
|
In interpolation when using expression mode ${} and having an illegal
name (e.g. _x) that resulted in a syntax error as the _x got translated
to a STRING token (a bare word not being a name). The interpolation
logic could then not transform it into a (valid) variable expression
(i.e. $_x).
The change is to let the lexer emit a WORD token for the illegal NAME.
The interpolation then changes that to a VARIBLE if it is the only
expression. If the WORD token escapes into the grammar, it is equivalent
to having used a quoted string in the source text.
Note that WORD only accepts unqualified input, anything with a : that is
not a valid NAME is still flagged as an error. Thus _x::y, x::_y are
both illegal NAME.
|
|
jpartlow/issue/master/pup-488-add-tests-for-resource-meta-parameter-access
(PUP-488) Add specs fur future Resource parameter/metaparameter access
|
|
This functionality was missing from the original work on supporting
the splat (unfold operator).
|
|
This is just adding a little additional spec coverage for the future
parser Resource[foo][attribute] syntax where attribute is either a
parameter or a metaparameter. It also checks some
virtual/realized/exported variations.
From debugging, it appears that the only values being accessed during
evaluation are those either set directly on the Puppet::Parser::Resource
instance's Puppet::Parser::Resource::Params, or the default
Puppet::Parser::Resource::Params which have been set in the current or
parent scopes during evaluation of a
Puppet::Pops::Model::ResourceDefaultsExpression for the given resource
type. No attempt is made to lookup the type class's defined parameter
defaults.
|
|
(PUP-2287) Fix lambda param with default is always choosen
|
|
(PUP-2240) Add unfold of array using splat unary * operator
|
|
There are several issues with the previously implemented support
where a parameterized Regexp was a stand in for a real regular
expression:
* The match variables where not set (and would be difficult to return
in general since Regexp's and Patterns can be nested in other types).
* Blurry line between what a Regexp type is, and String since Regexp[r]
produces a RegularExpression Type, not a Regexp instance.
This simply removes the special handling. A user can still use:
* Regexp (/..../)
* A String - transforms to a Regexp
* Pattern[p] type (since it is a real subtype of String)
|
|
This line of code missed the update to how Loaders are created because
it was done on a different branch.
|
|
The API for creating loaders was changed (now requiring an environment).
This updates the logic that used the old API.
|
|
This fixes the problem that a lambda parameter with a default always
was choosen even if a value was given for the parameter.
The expected behavior for function calls is that only truly missing (non
given) arguments are subjects to default value replacement, not if a
value is nil or undef. (This because functions are call by position, and
not call by name as for defines and classes). Thus all nil/undef values
are treated as any other value.
One test for the map function relied on the now fixed bug and it has
been marked pending, as it should be updated once the map function has
been transitioned to the new function API. (Where undef is not
transformed to empty string).
|
|
|
|
This adds the ability to unfold values into individual parameters
and entries in lists the same way as this is done in Ruby.
|
|
This makes the use of import statements raise an error.
The implementation reinstates "import" as a statement function. (This
is done by the factory when it finds a name followed by an expression
list).
Then, to raise the error, a function written with the function API
called 'import' raises an error.
This also introduced a way to raise errors based on the issue/acceptor
system. This new error type is called Puppet::Pops::SemanticError.
It is used to issue the discontinuation error. The error itself
refers to the deprecation URL which points to the relevant documentation
for manifest directory and import.
|
|
(PUP-2190) Fix issue when there are no defaults (for meta params)
|
|
The comparison used kind_of(), intead of kind_of?()
Test added.
|
|
When looking up a metaparameter - Notify['foo'][tag], this failed
when no tags had been set. The same problem would occur for any
parameter that the resource api reported to be a vaid parameter but
for which asking for its default did not return a Parameter.
|
|
The problem was that nil was not transformed to undef for the result
of a parameter default expression and nil was interpreted as value
missing by the 3x class/define logic.
This adds a transformation in the PopsBridge by introducing a new kind
of bridging expression. Likewise, a transformation was needed back again
to nil as the value was set in TypeCalculator when performing an
inference and symbol :undef can not be used where a String is expected.
It was also observed in PUP-1964 that the error that surfaced lacked
location information. This was caused by the transformation of
unparenthesized call, where the transformed call expression did not
get location information set.
Tests added for the two different problems.
The factory method for recording position now also checks if the
end_locateable is void of location information (which can happen
in some transformations).
|
|
This also fixes issues found by running the new tests and
debugging them.
|
|
The last segment of a qualified variable name is allowed to start
with an underscore. Previously this was only allowed for a single
segment.
|
|
Calling the type "Literal" was bad because it is used not only
for literal values entered in source code, but naturally also
for computed values. A commonly used name for these types is "Scalar".
This commit changes "Literal" to "Scalar" everywhere:
* class name PLiteralType => PScalarType
* its label
* factory methods "literal" => "scalar"
|
|
When turning on --strict_variables without also using --future parser
with the future evaluator, the raised error is an uncaught throw.
Now the error message is "Undefined Variable".
|
|
The way the implementation worked made it impossible to differentiate
between an instance and its type.
|