puppet 3.7.5-x64-mingw32 → 3.8.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/ext/build_defaults.yaml +5 -5
  3. data/lib/hiera/puppet_function.rb +15 -4
  4. data/lib/puppet.rb +5 -2
  5. data/lib/puppet/application/agent.rb +5 -0
  6. data/lib/puppet/application/apply.rb +5 -0
  7. data/lib/puppet/application/device.rb +8 -3
  8. data/lib/puppet/application/master.rb +5 -0
  9. data/lib/puppet/defaults.rb +8 -0
  10. data/lib/puppet/error.rb +27 -1
  11. data/lib/puppet/file_system.rb +13 -0
  12. data/lib/puppet/file_system/file19windows.rb +8 -0
  13. data/lib/puppet/file_system/file_impl.rb +4 -0
  14. data/lib/puppet/file_system/memory_impl.rb +4 -0
  15. data/lib/puppet/functions.rb +25 -3
  16. data/lib/puppet/functions/defined.rb +130 -0
  17. data/lib/puppet/functions/hiera_include.rb +1 -1
  18. data/lib/puppet/node/environment.rb +4 -0
  19. data/lib/puppet/parser/compiler.rb +5 -2
  20. data/lib/puppet/parser/functions/defined.rb +26 -1
  21. data/lib/puppet/parser/functions/file.rb +3 -1
  22. data/lib/puppet/parser/templatewrapper.rb +2 -1
  23. data/lib/puppet/pops.rb +5 -0
  24. data/lib/puppet/pops/evaluator/access_operator.rb +25 -5
  25. data/lib/puppet/pops/evaluator/collector_transformer.rb +1 -11
  26. data/lib/puppet/pops/evaluator/compare_operator.rb +43 -0
  27. data/lib/puppet/pops/evaluator/evaluator_impl.rb +43 -28
  28. data/lib/puppet/pops/evaluator/runtime3_support.rb +9 -5
  29. data/lib/puppet/pops/functions/dispatch.rb +6 -1
  30. data/lib/puppet/pops/issue_reporter.rb +42 -16
  31. data/lib/puppet/pops/issues.rb +96 -0
  32. data/lib/puppet/pops/loader/module_loaders.rb +3 -1
  33. data/lib/puppet/pops/loaders.rb +6 -4
  34. data/lib/puppet/pops/migration/migration_checker.rb +45 -0
  35. data/lib/puppet/pops/model/factory.rb +1 -1
  36. data/lib/puppet/pops/model/model_meta.rb +1 -1
  37. data/lib/puppet/pops/parser/egrammar.ra +1 -1
  38. data/lib/puppet/pops/parser/eparser.rb +1 -1
  39. data/lib/puppet/pops/parser/epp_support.rb +18 -9
  40. data/lib/puppet/pops/parser/evaluating_parser.rb +7 -1
  41. data/lib/puppet/pops/parser/heredoc_support.rb +12 -11
  42. data/lib/puppet/pops/parser/interpolation_support.rb +7 -1
  43. data/lib/puppet/pops/parser/lexer2.rb +8 -8
  44. data/lib/puppet/pops/parser/lexer_support.rb +46 -20
  45. data/lib/puppet/pops/parser/parser_support.rb +11 -14
  46. data/lib/puppet/pops/parser/slurp_support.rb +22 -6
  47. data/lib/puppet/pops/types/type_calculator.rb +156 -55
  48. data/lib/puppet/pops/types/type_factory.rb +67 -14
  49. data/lib/puppet/pops/types/type_parser.rb +22 -13
  50. data/lib/puppet/pops/types/types.rb +21 -3
  51. data/lib/puppet/pops/types/types_meta.rb +13 -2
  52. data/lib/puppet/pops/validation.rb +25 -2
  53. data/lib/puppet/pops/validation/checker4_0.rb +25 -5
  54. data/lib/puppet/provider/group/windows_adsi.rb +18 -6
  55. data/lib/puppet/provider/mount/parsed.rb +145 -2
  56. data/lib/puppet/provider/package/pip.rb +4 -5
  57. data/lib/puppet/provider/package/zypper.rb +17 -7
  58. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +35 -10
  59. data/lib/puppet/provider/service/init.rb +7 -0
  60. data/lib/puppet/provider/user/windows_adsi.rb +8 -1
  61. data/lib/puppet/provider/zpool/zpool.rb +7 -2
  62. data/lib/puppet/resource.rb +1 -1
  63. data/lib/puppet/type/group.rb +1 -1
  64. data/lib/puppet/type/mount.rb +14 -3
  65. data/lib/puppet/type/scheduled_task.rb +21 -6
  66. data/lib/puppet/util/log.rb +50 -8
  67. data/lib/puppet/util/log/destinations.rb +23 -2
  68. data/lib/puppet/util/logging.rb +37 -1
  69. data/lib/puppet/util/windows/adsi.rb +36 -11
  70. data/lib/puppet/version.rb +1 -1
  71. data/spec/fixtures/unit/provider/mount/parsed/aix.filesystems +93 -85
  72. data/spec/fixtures/unit/provider/mount/parsed/aix.mount +11 -7
  73. data/spec/integration/parser/collector_spec.rb +7 -0
  74. data/spec/integration/parser/future_compiler_spec.rb +9 -0
  75. data/spec/integration/parser/resource_expressions_spec.rb +3 -0
  76. data/spec/unit/file_system_spec.rb +38 -0
  77. data/spec/unit/functions/defined_spec.rb +291 -0
  78. data/spec/unit/functions/hiera_spec.rb +8 -6
  79. data/spec/unit/functions4_spec.rb +97 -2
  80. data/spec/unit/parser/functions/file_spec.rb +8 -2
  81. data/spec/unit/parser/functions/template_spec.rb +1 -1
  82. data/spec/unit/parser/templatewrapper_spec.rb +1 -1
  83. data/spec/unit/pops/evaluator/access_ops_spec.rb +19 -0
  84. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +61 -8
  85. data/spec/unit/pops/issues_spec.rb +16 -16
  86. data/spec/unit/pops/loaders/module_loaders_spec.rb +5 -0
  87. data/spec/unit/pops/migration_spec.rb +180 -0
  88. data/spec/unit/pops/parser/lexer2_spec.rb +152 -1
  89. data/spec/unit/pops/parser/parse_heredoc_spec.rb +26 -0
  90. data/spec/unit/pops/transformer/transform_calls_spec.rb +1 -1
  91. data/spec/unit/pops/types/type_calculator_spec.rb +204 -11
  92. data/spec/unit/pops/validation_spec.rb +66 -0
  93. data/spec/unit/provider/group/windows_adsi_spec.rb +65 -1
  94. data/spec/unit/provider/mount/parsed_spec.rb +31 -5
  95. data/spec/unit/provider/package/pip_spec.rb +19 -7
  96. data/spec/unit/provider/package/zypper_spec.rb +25 -14
  97. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +312 -70
  98. data/spec/unit/provider/service/base_spec.rb +42 -31
  99. data/spec/unit/provider/service/freebsd_spec.rb +1 -0
  100. data/spec/unit/provider/service/gentoo_spec.rb +1 -0
  101. data/spec/unit/provider/service/init_spec.rb +18 -0
  102. data/spec/unit/provider/service/openbsd_spec.rb +1 -0
  103. data/spec/unit/provider/service/redhat_spec.rb +1 -0
  104. data/spec/unit/provider/user/windows_adsi_spec.rb +21 -0
  105. data/spec/unit/provider/zpool/zpool_spec.rb +47 -10
  106. data/spec/unit/util/log_spec.rb +113 -0
  107. data/spec/unit/util/windows/adsi_spec.rb +106 -26
  108. metadata +10 -2
@@ -1,4 +1,4 @@
1
- require 'hiera_puppet'
1
+ require 'hiera/puppet_function'
2
2
 
3
3
  # Assigns classes to a node using an array merge lookup that retrieves the value for a user-specified key
4
4
  # from a Hiera data source.
@@ -568,6 +568,10 @@ class Puppet::Node::Environment
568
568
  parser.parse
569
569
  end
570
570
  end
571
+ rescue Puppet::ParseErrorWithIssue => detail
572
+ @known_resource_types.parse_failed = true
573
+ detail.environment = self.name
574
+ raise
571
575
  rescue => detail
572
576
  @known_resource_types.parse_failed = true
573
577
 
@@ -32,6 +32,10 @@ class Puppet::Parser::Compiler
32
32
  end
33
33
 
34
34
  new(node).compile {|resulting_catalog| resulting_catalog.to_resource }
35
+ rescue Puppet::ParseErrorWithIssue => detail
36
+ detail.node = node.name
37
+ Puppet.log_exception(detail)
38
+ raise
35
39
  rescue => detail
36
40
  message = "#{detail} on node #{node.name}"
37
41
  Puppet.log_exception(detail, message)
@@ -150,8 +154,7 @@ class Puppet::Parser::Compiler
150
154
 
151
155
  # Constructs the overrides for the context
152
156
  def context_overrides()
153
- if Puppet.future_parser?
154
- require 'puppet/loaders'
157
+ if Puppet.future_parser?(environment)
155
158
  {
156
159
  :current_environment => environment,
157
160
  :global_scope => @topscope, # 4x placeholder for new global scope
@@ -38,8 +38,33 @@ Puppet::Parser::Functions::newfunction(:defined, :type => :rvalue, :arity => -2,
38
38
  defined(File[\'/some/file\'])
39
39
  defined(Class[\'foo\'])
40
40
 
41
+ The `defined` function does not answer if 4.x data types (e.g. `Integer`) are defined. If
42
+ given the string 'integer' the result is false, and if given a non CatalogEntry type,
43
+ an error is raised.
44
+
45
+ The rules for asking for undef, empty strings, and the main class are different from 3.x
46
+ (non future parser) and 4.x (with future parser or in Puppet 4.0.0 and later):
47
+
48
+ defined('') # 3.x => true, 4.x => false
49
+ defined(undef) # 3.x => true, 4.x => error
50
+ defined('main') # 3.x => false, 4.x => true
51
+
52
+ With the future parser, it is also possible to ask specifically if a name is
53
+ a resource type (built in or defined), or a class, by giving its type:
54
+
55
+ defined(Type[Class['foo']])
56
+ defined(Type[Resource['foo']])
57
+
58
+ Which is different from asking:
59
+
60
+ defined('foo')
61
+
62
+ Since the later returns true if 'foo' is either a class, a built-in resource type, or a user defined
63
+ resource type, and a specific request like `Type[Class['foo']]` only returns true if `'foo'` is a class.
64
+
41
65
  - Since 2.7.0
42
- - Since 3.6.0 variable reference and future parser types") do |vals|
66
+ - Since 3.6.0 variable reference and future parser types
67
+ - Since 3.8.1 type specific requests with future parser") do |vals|
43
68
  vals = [vals] unless vals.is_a?(Array)
44
69
  vals.any? do |val|
45
70
  case val
@@ -1,3 +1,5 @@
1
+ require 'puppet/file_system'
2
+
1
3
  Puppet::Parser::Functions::newfunction(
2
4
  :file, :arity => -2, :type => :rvalue,
3
5
  :doc => "Loads a file from a module and returns its contents as a string.
@@ -24,7 +26,7 @@ Puppet::Parser::Functions::newfunction(
24
26
  end
25
27
 
26
28
  if path
27
- File.read(path)
29
+ Puppet::FileSystem.read_preserve_line_endings(path)
28
30
  else
29
31
  raise Puppet::ParseError, "Could not find any files from #{vals.join(", ")}"
30
32
  end
@@ -1,5 +1,6 @@
1
1
  require 'puppet/parser/files'
2
2
  require 'erb'
3
+ require 'puppet/file_system'
3
4
 
4
5
  # A simple wrapper for templates, so they don't have full access to
5
6
  # the scope objects.
@@ -97,7 +98,7 @@ class Puppet::Parser::TemplateWrapper
97
98
  if string
98
99
  template_source = "inline template"
99
100
  else
100
- string = File.read(@__file__)
101
+ string = Puppet::FileSystem.read_preserve_line_endings(@__file__)
101
102
  template_source = @__file__
102
103
  end
103
104
 
data/lib/puppet/pops.rb CHANGED
@@ -119,9 +119,14 @@ module Puppet
119
119
  require 'puppet/pops/functions/dispatch'
120
120
  require 'puppet/pops/functions/dispatcher'
121
121
  end
122
+
123
+ module Migration
124
+ require 'puppet/pops/migration/migration_checker'
125
+ end
122
126
  end
123
127
 
124
128
  require 'puppet/parser/ast/pops_bridge'
125
129
  require 'puppet/bindings'
126
130
  require 'puppet/functions'
131
+ require 'puppet/loaders'
127
132
  end
@@ -254,17 +254,37 @@ class Puppet::Pops::Evaluator::AccessOperator
254
254
  def access_POptionalType(o, scope, keys)
255
255
  keys.flatten!
256
256
  if keys.size == 1
257
- unless keys[0].is_a?(Puppet::Pops::Types::PAnyType)
258
- fail(Puppet::Pops::Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'Optional-Type', :actual => keys[0].class})
257
+ type = keys[0]
258
+ unless type.is_a?(Puppet::Pops::Types::PAnyType) || type.is_a?(String)
259
+ fail(Puppet::Pops::Issues::BAD_TYPE_SLICE_TYPE, @semantic.keys[0], {:base_type => 'Optional-Type', :actual => type.class})
259
260
  end
260
- result = Puppet::Pops::Types::POptionalType.new()
261
- result.optional_type = keys[0]
262
- result
261
+ TYPEFACTORY.optional(type)
263
262
  else
264
263
  fail(Puppet::Pops::Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'Optional-Type', :min => 1, :actual => keys.size})
265
264
  end
266
265
  end
267
266
 
267
+ def access_PNotUndefType(o, scope, keys)
268
+ keys.flatten!
269
+ case keys.size
270
+ when 0
271
+ TYPEFACTORY.not_undef
272
+ when 1
273
+ type = keys[0]
274
+ case type
275
+ when String
276
+ type = TYPEFACTORY.string(type)
277
+ when Puppet::Pops::Types::PAnyType
278
+ type = nil if type.class == Puppet::Pops::Types::PAnyType
279
+ else
280
+ fail(Puppet::Pops::Issues::BAD_NOT_UNDEF_SLICE_TYPE, @semantic.keys[0], {:base_type => 'NotUndef-Type', :actual => type.class})
281
+ end
282
+ TYPEFACTORY.not_undef(type)
283
+ else
284
+ fail(Puppet::Pops::Issues::BAD_TYPE_SLICE_ARITY, @semantic, {:base_type => 'NotUndef-Type', :min => 0, :max => 1, :actual => keys.size})
285
+ end
286
+ end
287
+
268
288
  def access_PType(o, scope, keys)
269
289
  keys.flatten!
270
290
  if keys.size == 1
@@ -27,7 +27,7 @@ class Puppet::Pops::Evaluator::CollectorTransformer
27
27
 
28
28
  if !o.operations.empty?
29
29
  overrides = {
30
- :parameters => o.operations.map{ |x| to_3x_param(x).evaluate(scope)},
30
+ :parameters => o.operations.map{ |x| @@evaluator.evaluate(x, scope)}.flatten,
31
31
  :file => file_path,
32
32
  :line => [line_num, position],
33
33
  :source => scope.source,
@@ -206,14 +206,4 @@ protected
206
206
  def match_Object(o, scope)
207
207
  raise ArgumentError, "Cannot transform object of class #{o.class}"
208
208
  end
209
-
210
- # Produces (name => expr) or (name +> expr)
211
- def to_3x_param(o)
212
- bridge = Puppet::Parser::AST::PopsBridge::Expression.new(:value => o.value_expr)
213
- args = { :value => bridge }
214
- args[:add] = true if o.operator == :'+>'
215
- args[:param] = o.attribute_name
216
- args= Puppet::Pops::Model::AstTransformer.new().merge_location(args, o)
217
- Puppet::Parser::AST::ResourceParam.new(args)
218
- end
219
209
  end
@@ -17,6 +17,7 @@ class Puppet::Pops::Evaluator::CompareOperator
17
17
  def initialize
18
18
  @@equals_visitor ||= Puppet::Pops::Visitor.new(self, "equals", 1, 1)
19
19
  @@compare_visitor ||= Puppet::Pops::Visitor.new(self, "cmp", 1, 1)
20
+ @@match_visitor ||= Puppet::Pops::Visitor.new(self, "match", 2, 2)
20
21
  @@include_visitor ||= Puppet::Pops::Visitor.new(self, "include", 2, 2)
21
22
  @type_calculator = Puppet::Pops::Types::TypeCalculator.new()
22
23
  end
@@ -31,6 +32,11 @@ class Puppet::Pops::Evaluator::CompareOperator
31
32
  @@compare_visitor.visit_this_1(self, a, b)
32
33
  end
33
34
 
35
+ # Performs a match of a and b, and returns true if b matches a
36
+ def match(a, b, scope)
37
+ @@match_visitor.visit_this_2(self, b, a, scope)
38
+ end
39
+
34
40
  # Answers is b included in a
35
41
  def include?(a, b, scope)
36
42
  @@include_visitor.visit_this_2(self, a, b, scope)
@@ -149,4 +155,41 @@ class Puppet::Pops::Evaluator::CompareOperator
149
155
  def include_Hash(a, b, scope)
150
156
  include?(a.keys, b, scope)
151
157
  end
158
+
159
+ # Matches in general by using == operator
160
+ def match_Object(pattern, a, scope)
161
+ equals(a, pattern)
162
+ end
163
+
164
+ # Matches only against strings
165
+ def match_Regexp(regexp, left, scope)
166
+ return false unless left.is_a? String
167
+ matched = regexp.match(left)
168
+ set_match_data(matched, scope) # creates or clears ephemeral
169
+ !!matched # convert to boolean
170
+ end
171
+
172
+ def match_PAnyType(any_type, left, scope)
173
+ # right is a type and left is not - check if left is an instance of the given type
174
+ # (The reverse is not terribly meaningful - computing which of the case options that first produces
175
+ # an instance of a given type).
176
+ #
177
+ @type_calculator.instance?(any_type, left)
178
+ end
179
+
180
+ def match_Array(array, left, scope)
181
+ return false unless left.is_a?(Array)
182
+ return false unless left.length == array.length
183
+ array.each_with_index.all? { | pattern, index| match(left[index], pattern, scope) }
184
+ end
185
+
186
+ def match_Hash(hash, left, scope)
187
+ return false unless left.is_a?(Hash)
188
+ hash.all? {|x,y| match(left[x], y, scope) }
189
+ end
190
+
191
+ def match_Symbol(symbol, left, scope)
192
+ return true if symbol == :default
193
+ equals(left, default, scope)
194
+ end
152
195
  end
@@ -53,6 +53,9 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
53
53
 
54
54
  @@compare_operator ||= Puppet::Pops::Evaluator::CompareOperator.new()
55
55
  @@relationship_operator ||= Puppet::Pops::Evaluator::RelationshipOperator.new()
56
+
57
+ # Use null migration checker unless given in context
58
+ @migration_checker = (Puppet.lookup(:migration_checker) { Puppet::Pops::Migration::MigrationChecker.new() })
56
59
  end
57
60
 
58
61
  # @api private
@@ -254,7 +257,7 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
254
257
  end
255
258
 
256
259
  def eval_NotExpression(o, scope)
257
- ! is_true?(evaluate(o.expr, scope))
260
+ ! is_true?(evaluate(o.expr, scope), o.expr)
258
261
  end
259
262
 
260
263
  def eval_UnaryMinusExpression(o, scope)
@@ -404,14 +407,19 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
404
407
  left = evaluate(o.left_expr, scope)
405
408
  right = evaluate(o.right_expr, scope)
406
409
 
410
+ @migration_checker.report_uc_bareword_type(left, o.left_expr)
411
+ @migration_checker.report_uc_bareword_type(right, o.right_expr)
412
+
407
413
  begin
408
414
  # Left is a type
409
415
  if left.is_a?(Puppet::Pops::Types::PAnyType)
410
416
  case o.operator
411
417
  when :'=='
418
+ @migration_checker.report_equality_type_mismatch(left, right, o)
412
419
  @@type_calculator.equals(left,right)
413
420
 
414
421
  when :'!='
422
+ @migration_checker.report_equality_type_mismatch(left, right, o)
415
423
  !@@type_calculator.equals(left,right)
416
424
 
417
425
  when :'<'
@@ -432,8 +440,10 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
432
440
  else
433
441
  case o.operator
434
442
  when :'=='
443
+ @migration_checker.report_equality_type_mismatch(left, right, o)
435
444
  @@compare_operator.equals(left,right)
436
445
  when :'!='
446
+ @migration_checker.report_equality_type_mismatch(left, right, o)
437
447
  ! @@compare_operator.equals(left,right)
438
448
  when :'<'
439
449
  @@compare_operator.compare(left,right) < 0
@@ -478,6 +488,8 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
478
488
  left = evaluate(o.left_expr, scope)
479
489
  pattern = evaluate(o.right_expr, scope)
480
490
 
491
+ @migration_checker.report_uc_bareword_type(left, o.left_expr)
492
+
481
493
  # matches RHS types as instance of for all types except a parameterized Regexp[R]
482
494
  if pattern.is_a?(Puppet::Pops::Types::PAnyType)
483
495
  # evaluate as instance? of type check
@@ -507,6 +519,8 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
507
519
  def eval_InExpression o, scope
508
520
  left = evaluate(o.left_expr, scope)
509
521
  right = evaluate(o.right_expr, scope)
522
+ @migration_checker.report_uc_bareword_type(left, o.left_expr)
523
+ @migration_checker.report_in_expression(o)
510
524
  @@compare_operator.include?(right, left, scope)
511
525
  end
512
526
 
@@ -515,7 +529,7 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
515
529
  # b is only evaluated if a is true
516
530
  #
517
531
  def eval_AndExpression o, scope
518
- is_true?(evaluate(o.left_expr, scope)) ? is_true?(evaluate(o.right_expr, scope)) : false
532
+ is_true?(evaluate(o.left_expr, scope), o.left_expr) ? is_true?(evaluate(o.right_expr, scope), o.right_expr) : false
519
533
  end
520
534
 
521
535
  # @example
@@ -523,7 +537,7 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
523
537
  # b is only evaluated if a is false
524
538
  #
525
539
  def eval_OrExpression o, scope
526
- is_true?(evaluate(o.left_expr, scope)) ? true : is_true?(evaluate(o.right_expr, scope))
540
+ is_true?(evaluate(o.left_expr, scope), o.left_expr) ? true : is_true?(evaluate(o.right_expr, scope), o.right_expr)
527
541
  end
528
542
 
529
543
  # Evaluates each entry of the literal list and creates a new Array
@@ -562,21 +576,24 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
562
576
  #
563
577
  with_guarded_scope(scope) do
564
578
  test = evaluate(o.test, scope)
579
+ @migration_checker.report_uc_bareword_type(test, o.test)
580
+
565
581
  result = nil
566
582
  the_default = nil
567
583
  if o.options.find do |co|
568
584
  # the first case option that matches
569
585
  if co.values.find do |c|
586
+ c = unwind_parentheses(c)
570
587
  case c
571
588
  when Puppet::Pops::Model::LiteralDefault
572
589
  the_default = co.then_expr
573
- is_match?(test, evaluate(c, scope), c, scope)
590
+ next false
574
591
  when Puppet::Pops::Model::UnfoldExpression
575
592
  # not ideal for error reporting, since it is not known which unfolded result
576
593
  # that caused an error - the entire unfold expression is blamed (i.e. the var c, passed to is_match?)
577
- evaluate(c, scope).any? {|v| is_match?(test, v, c, scope) }
594
+ evaluate(c, scope).any? {|v| is_match?(test, v, c, co, scope) }
578
595
  else
579
- is_match?(test, evaluate(c, scope), c, scope)
596
+ is_match?(test, evaluate(c, scope), c, co, scope)
580
597
  end
581
598
  end
582
599
  result = evaluate(co.then_expr, scope)
@@ -800,13 +817,13 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
800
817
  unless o.functor_expr.is_a? Puppet::Pops::Model::NamedAccessExpression
801
818
  fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function accessor', :container => o})
802
819
  end
803
- receiver = evaluate(o.functor_expr.left_expr, scope)
820
+ receiver = unfold([], [o.functor_expr.left_expr], scope)
804
821
  name = o.functor_expr.right_expr
805
822
  unless name.is_a? Puppet::Pops::Model::QualifiedName
806
823
  fail(Issues::ILLEGAL_EXPRESSION, o.functor_expr, {:feature=>'function name', :container => o})
807
824
  end
808
825
  name = name.value # the string function name
809
- call_function_with_block(name, unfold([receiver], o.arguments || [], scope), o, scope)
826
+ call_function_with_block(name, unfold(receiver, o.arguments || [], scope), o, scope)
810
827
  end
811
828
 
812
829
  def call_function_with_block(name, evaluated_arguments, o, scope)
@@ -892,9 +909,11 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
892
909
  #
893
910
  with_guarded_scope(scope) do
894
911
  test = evaluate(o.left_expr, scope)
912
+ @migration_checker.report_uc_bareword_type(test, o.left_expr)
913
+
895
914
  the_default = nil
896
915
  selected = o.selectors.find do |s|
897
- me = s.matching_expr
916
+ me = unwind_parentheses(s.matching_expr)
898
917
  case me
899
918
  when Puppet::Pops::Model::LiteralDefault
900
919
  the_default = s.value_expr
@@ -902,9 +921,9 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
902
921
  when Puppet::Pops::Model::UnfoldExpression
903
922
  # not ideal for error reporting, since it is not known which unfolded result
904
923
  # that caused an error - the entire unfold expression is blamed (i.e. the var c, passed to is_match?)
905
- evaluate(me, scope).any? {|v| is_match?(test, v, me, scope) }
924
+ evaluate(me, scope).any? {|v| is_match?(test, v, me, s, scope) }
906
925
  else
907
- is_match?(test, evaluate(me, scope), me, scope)
926
+ is_match?(test, evaluate(me, scope), me, s, scope)
908
927
  end
909
928
  end
910
929
  if selected
@@ -932,7 +951,7 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
932
951
  # Evaluates Puppet DSL `if`
933
952
  def eval_IfExpression o, scope
934
953
  with_guarded_scope(scope) do
935
- if is_true?(evaluate(o.test, scope))
954
+ if is_true?(evaluate(o.test, scope), o.test)
936
955
  evaluate(o.then_expr, scope)
937
956
  else
938
957
  evaluate(o.else_expr, scope)
@@ -943,7 +962,7 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
943
962
  # Evaluates Puppet DSL `unless`
944
963
  def eval_UnlessExpression o, scope
945
964
  with_guarded_scope(scope) do
946
- unless is_true?(evaluate(o.test, scope))
965
+ unless is_true?(evaluate(o.test, scope), o.test)
947
966
  evaluate(o.then_expr, scope)
948
967
  else
949
968
  evaluate(o.else_expr, scope)
@@ -1144,22 +1163,12 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
1144
1163
  # This is the type of matching performed in a case option, using == for every type
1145
1164
  # of value except regular expression where a match is performed.
1146
1165
  #
1147
- def is_match? left, right, o, scope
1148
- if right.is_a?(Regexp)
1149
- return false unless left.is_a? String
1150
- matched = right.match(left)
1151
- set_match_data(matched, scope) # creates or clears ephemeral
1152
- !!matched # convert to boolean
1153
- elsif right.is_a?(Puppet::Pops::Types::PAnyType)
1154
- # right is a type and left is not - check if left is an instance of the given type
1155
- # (The reverse is not terribly meaningful - computing which of the case options that first produces
1156
- # an instance of a given type).
1157
- #
1158
- @@type_calculator.instance?(right, left)
1159
- else
1160
- # Handle equality the same way as the language '==' operator (case insensitive etc.)
1161
- @@compare_operator.equals(left,right)
1166
+ def is_match?(left, right, o, option_expr, scope)
1167
+ @migration_checker.report_option_type_mismatch(left, right, option_expr, o)
1168
+ if right.is_a?(Puppet::Pops::Types::PAnyType)
1169
+ @migration_checker.report_uc_bareword_type(right, o)
1162
1170
  end
1171
+ @@compare_operator.match(left, right, scope)
1163
1172
  end
1164
1173
 
1165
1174
  def with_guarded_scope(scope)
@@ -1180,6 +1189,7 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
1180
1189
  #
1181
1190
  def unfold(result, array, scope)
1182
1191
  array.each do |x|
1192
+ x = unwind_parentheses(x)
1183
1193
  if x.is_a?(Puppet::Pops::Model::UnfoldExpression)
1184
1194
  result.concat(evaluate(x, scope))
1185
1195
  else
@@ -1190,4 +1200,9 @@ class Puppet::Pops::Evaluator::EvaluatorImpl
1190
1200
  end
1191
1201
  private :unfold
1192
1202
 
1203
+ def unwind_parentheses(o)
1204
+ return o unless o.is_a?(Puppet::Pops::Model::ParenthesizedExpression)
1205
+ unwind_parentheses(o.expr)
1206
+ end
1207
+ private :unwind_parentheses
1193
1208
  end