Age | Commit message (Collapse) | Author | Files | Lines |
|
The type calculator did not correctly compute assignability for
a non parameterized Pattern. Such a Pattern is equal to "any string",
and is thus assignable from any other Pattern, Enum or String.
This was missing in the calculator and this resulted in Pattern neither
being equal to, less than, or greater than parameterized patterns.
|
|
For PUP-2857 :undef was changed from being a PNilType to a PRuntimeType.
This stopped the undef literal in the language from being able to be
assigned to Optional parameters. However, this only happened when the
undef was the default expression for the parameter.
|
|
PUP-3366 Fix issues with string/enum type assignable calculations
|
|
* 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.
|
|
hlindberg/PUP-3365_remove-deep-undef-mapping-in-3x-func-api
(PUP-3365) Change 3x deep map of undef to only do surface map
|
|
Comparissons involving an unparentesized Enum were not correct
because an iteration with all? returns true if the set being
enumerated is empty.
This modifies the logic, and adds missing tests.
|
|
This fixes problems when a user enters commas where they are not
supposed to be. As a result, an expression will be parsed as being an
argument list for an unparenthesized function call. The transformation
logic for such calls did not take one case into account; a non call
followed by an argument list. e.g:
$a = 1,10
Which resulted in a strange AST model (a literal list with an assignment
and a 10).
This commit adds error checking and raising of an exception in the
transformation which is caught by parser_support and formatted into an
error - either about an illegal comma (when the LHS cannot possibly be
a call at all (as in the above exampel), or a more elaborate
message about that what could be a function call requires parentheses.
In order to enable positioning of the error message on the first comma
in the argumet list, the comma tokens were required in the expression
list fed to the transformer. Subsequently these tokens must be filtered
out by the transformation, and passed on in the raised exception (since
the receiver would otherwise not know which token that caused the
problem (it is nested inside the stucture it passes on to be
transformed).
Unparenthesized function calls are a very bad idea...
|
|
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.
|
|
There were errors in the calculation of string/enum calculation.
Basically Enum == String, if String is size constrained then
Enum < String. This fixes this calculation.
There were no tests for this, they are now added.
|
|
|
|
The loaders previously assumed that any installation of puppet would be
under a directory called lib. This holds true when running puppet from
source (during development), or in some package cases, but is not
generally true. This simplifying assumption was made so that the loading
path for both puppet system extensions (built in functions) and module
extensions could be loaded in the same manner: find the root of the
extender and loading code from `lib/puppet/...`.
This changes to loading to instead only assume that there is a `puppet`
directory and not the name of the parent. This, however, forces the
loader for modules to become specialized to only be able to find ruby
extentions, because they are in the 'lib' directory, which is how the
loader must now be configured.
|
|
hlindberg/PUP-3117_resource-expression-splat-rocket-alt
(PUP-3117) Complete the Resource Expression implementation
|
|
There was a typo in the message that referenced a non existing variable.
This was undetected because there was no test to cover this.
When testing the expected behavior, it was found that the validation
was not correct as it allowed parameters to have hexadecimal names, but
not octal names. Now all numeric parameter names are disallowed (they
cannot be used or addressed anyway).
|
|
snippets
In the puppet 4.0 parser, the file resource's mode property will be
required to be a string containing an octal (or symbolic) representation
of mode.
For consistency then, this commit changes all cases where mode was
specified as a Numeric to be a string containing an octal representation
of mode (always prefaced with a 0, again for clarity and consistency).
|
|
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.
|
|
There was a regression in the future parser in d25e462 which caused
resources with multiple attributeless bodies constructed like this:
file {
'/foo':;
'/bar':;
}
to fail because the future parser grammar was not allowing the terminal
semicolon. The acceptance suite picked this up running with parser
future. It slipped past specs because, even though we have a spec
testing multiple attributeless resource bodies, it lacked a terminal
semicolon.
Henrik Lindberg figured out the minor egrammar fix here to correct the
expression, and a test case is added to catch it in specs.
|
|
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.
|
|
The implementation no longer needs to transform resource expressions
to 3x AST. This changes the transformer to raise an error if attempted.
The spec test for resource transformation is also dropped. No new
test added that transformer raises exceptions for resource
transformation since all transformation eventually will be dropped.
|
|
Since all types now are PAnyType, there is no need to have
an extra abstratin called PAbstractType, it just adds level in
the ancestor hierarchy that needs to be consulted for methods, one
extra step to go when checking is_a? against PAbstractType instead of
PAnyType, etc.
|
|
The old (intermediate) lexer was still hanging around even if it was
not being used. Cycles were also wasted on unit testing it.
The new lexer "Lexer2" has been in use for quite some time and the
old lexer is not useful even as a reference at this point.
This speeds up both loading and unit testing.
|
|
Because of the order Travis runs specs, some environment caching issues
were found that caused some specs to fail because they made the
assumption that the production environment wasn't already in the cache.
Thus, they relied on changing Puppet[:modulepath] to have an effect.
The fix is to override the environments for these two
specs and return an environment we know has the expected module path.
|
|
Maint/master/update rspec
|
|
This adds validation of reserved parameter names; $name and $title
that, if they are used will cause problems later in the production
of a catalog.
The implementation performs the checks as part of validation of
the parsed puppet logic.
|
|
(PUP-2886) Add validation for reserved type names
|
|
From RSpec:
DEPRECATION: `expect { }.not_to raise_error(SpecificErrorClass, message)` is deprecated. Use `expect { }.not_to raise_error` (with no args) instead.
This commit removes all args from `.to_not raise_error` expectations.
|
|
An empty program (one without any expressions except "no-op") did
not produce an instance of Model::Program. This is bad because it
is of value to get the lexed/parsed model with line references for
comment processing and other static analysis of the source.
Now, an empty program will produce a Model::Program containing a single
Model::Nop instruction. This instruction has offset at "EOF", and a
length of 0 (thus, any comments in the input source are guaranteed to be
placed before this nop.
|
|
(PUP-2693) Fix length calculation for sq-string
|
|
(PUP-2807) Add output of containing scope for log functions
|
|
(PUP-2831) Make Puppet work with RGen 0.7.0
|
|
* pr/2819:
(maint) Remove biff setting and related code
(PUP-2858) Remove evaluator setting
(PUP-2858) Remove duplicated testing (evaluator = 'current')
(PUP-2858) Refactor binder to use ne evaluator
(PUP-2858) Remove the 3_1 checker and its factory
(PUP-2858) Refactor EvaluatingParser::Transitional to EvaluatingParser
(PUP-2858) Remove use of Puppet[:evaluator] from the code base
(PUP-2858) Deprecate the use of Puppet[:environment] == current
(PUP-2858) Remove e_parser adapter support
Conflicts:
spec/integration/node/environment_spec.rb
Closes #2819
|
|
The Biff setting is not one that we need in the 3.x series. The work
that it was for was halted and will be picked up at a later date.
|
|
Before this change, the special value produced by a default expression
was treated as a Ruby['Symbol'] (later changed to Runtime['ruby',
'Symbol']). This commit changes this to produce an instance of a
new type called Default.
The Default type is an Any, but is not assignable to anything else.
This also removes the inference of :undef to PNilType (a.k.a Undef
in the Puppet Language). The reason for this, now that :undef is
never used by the evaluator. Thus, if someone were to return :undef, or
have it in a data structure, the type calculator would falsely
inferr it as an Undef / NilType. Now, instead, it will be inferred
as a Runtime['ruby', 'Symbol'] and this makes it more clear to
a user that they leaked an :undef in error.
As a consequence several tests that used :undef needed to be changed.
|
|
This changes the type Ruby[class_name] to the more generic
Runtime[ruby, runtime_type_name] to avoid squatting on open
set of names for potential runtimes which may clash with managment
of the same runtime via a Puppet class or define.
After this change, all references to Ruby[name] should be replaced
with Runtime[ruby,name].
|
|
(PUP-2833) Make all types inherit PAnyType
|
|
(PUP-2794) Change Callable to mean "can be called with"
|
|
Before this it was possible to name classes and defines with
words that are reserved by the type system (e.g. 'integer'), while
the name is not a type (Integer is a type, but integer is not), the
definitions will automatically create a resource type named with
an upper case initial letter, and will thus be difficult to reference.
For that reason it is better to error on these names statically.
|
|
This removes the Checker_3_1 and its factory from the code base.
This hybrid checker contained less validation (less string) than
the 4.0 checker and its main purpose was to fail expressions that
could not be evaluated with the 3x AST based evaluation (such as -=).
It is also not meaningful to continue its development as the new
4_0 checker is far better. If there is a later need to check
for "backwards compatibility" to 3x, it is better to start fresh with a
new copy of the 4_0 evaluator.
|
|
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.
|
|
There was a problem with the check for empty range, as the size
of a range Integer[0,0] is not 0, but 1 (there is a 0 in the range).
Also adds test to check that type parser produces a Callable with
a Unit type when the range so requires.
|
|
This adds a type named Unit, that is an "undef of sort" in that
it is assignable to anything, and anything can be assigned to it.
This type is not exposed in the Puppet Language, and it is only
used in Callables to describe that there is no type requirement on
a parameter. (For cases where reflection of a given lambda is
performed etc. or where the error raised when calling a block
is an acceptable solution).
|
|
|
|
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-2845) Move epp functions
|
|
It is more meaningful to check that a Callable can be called with
certain types (exact or more generic) than to check the reverse.
This alters the meaning of Callable assignability so that a more generic
Callable is accepted. While this seems counterintuitive from the
perspective of the type system, it is the constraint that is expected as
the constraint being expressed means "Must be callable with arguments of
these types", and a more generic callable is just that.
The current implementation got that wrong, and will actually accept
callables that can in fact not be called.
This also alters the assert_type function that declared that it would
call a given block with Any, Any, when in fact it will call with
Type, Type.
Note, that a function that after this delares that it calls
Callable[Any] will enforce that the given callable is Any. If the intent
is to accept any callable, the type should be given as just Callable.
|
|
* pr/2810:
(maint) Extract constant for name separator
(PUP-2654) Capitalize each segment of a resource type "label"
|
|
This corrects a problem where Enum[a] was not assignable to
Enum[a,b], since it is a subset, it should be assignable.
|
|
(PUP-1811) Make 'in' set match vars when regexp is used to match
|