puppet 3.7.5-x86-mingw32 → 3.8.1-x86-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
@@ -316,7 +316,7 @@ module Puppet::Pops::Evaluator::Runtime3Support
316
316
  # for the type of the name.
317
317
  # Note, locations are available per parameter.
318
318
  #
319
- scope.define_settings(capitalize_qualified_name(type_name), evaluated_parameters)
319
+ scope.define_settings(capitalize_qualified_name(type_name), evaluated_parameters.flatten)
320
320
  end
321
321
 
322
322
  # Capitalizes each segment of a qualified name
@@ -335,7 +335,8 @@ module Puppet::Pops::Evaluator::Runtime3Support
335
335
  # TODO: Revisit and possible improve the accuracy.
336
336
  #
337
337
  file, line = extract_file_line(o)
338
-
338
+ # A *=> results in an array of arrays
339
+ evaluated_parameters = evaluated_parameters.flatten
339
340
  evaluated_resources.each do |r|
340
341
  unless r.is_a?(Puppet::Pops::Types::PResourceType) && r.type_name != 'class'
341
342
  fail(Puppet::Pops::Issues::ILLEGAL_OVERRIDEN_TYPE, o, {:actual => r} )
@@ -409,15 +410,18 @@ module Puppet::Pops::Evaluator::Runtime3Support
409
410
 
410
411
  # This is the same type of "truth" as used in the current Puppet DSL.
411
412
  #
412
- def is_true? o
413
+ def is_true?(value, o)
413
414
  # Is the value true? This allows us to control the definition of truth
414
415
  # in one place.
415
- case o
416
+ case value
416
417
  # Support :undef since it may come from a 3x structure
417
418
  when :undef
418
419
  false
420
+ when String
421
+ @migration_checker.report_empty_string_true(value, o)
422
+ true
419
423
  else
420
- !!o
424
+ !!value
421
425
  end
422
426
  end
423
427
 
@@ -71,7 +71,12 @@ class Puppet::Pops::Functions::Dispatch < Puppet::Pops::Evaluator::CallableSigna
71
71
  else
72
72
  # Careful so no new nil arguments are added since they would override default
73
73
  # parameter values in the received
74
- new_args << args[knit] if knit < args.size
74
+ if knit < 0
75
+ idx = -knit - 1
76
+ new_args += args[idx..-1] if idx < args.size
77
+ else
78
+ new_args << args[knit] if knit < args.size
79
+ end
75
80
  end
76
81
  end
77
82
  new_args
@@ -11,19 +11,14 @@ class Puppet::Pops::IssueReporter
11
11
  def self.assert_and_report(acceptor, options)
12
12
  return unless acceptor
13
13
 
14
- max_errors = Puppet[:max_errors]
15
- max_warnings = Puppet[:max_warnings]
16
- max_deprecations =
17
- if Puppet[:disable_warnings].include?('deprecations')
18
- 0
19
- else
20
- Puppet[:max_deprecations]
21
- end
14
+ max_errors = options[:max_errors] || Puppet[:max_errors]
15
+ max_warnings = options[:max_warnings] || Puppet[:max_warnings]
16
+ max_deprecations = options[:max_deprecations] || (Puppet[:disable_warnings].include?('deprecations') ? 0 : Puppet[:max_deprecations])
22
17
 
23
- emit_warnings = options[:emit_warnings] || false
24
- emit_errors = options[:emit_errors].nil? ? true : !!options[:emit_errors]
25
- emit_message = options[:message]
26
- emit_exception = options[:exception_class] || Puppet::ParseError
18
+ emit_warnings = options[:emit_warnings] || false
19
+ emit_errors = options[:emit_errors].nil? ? true : !!options[:emit_errors]
20
+ emit_message = options[:message]
21
+ emit_exception = options[:exception_class] || Puppet::ParseErrorWithIssue
27
22
 
28
23
  # If there are warnings output them
29
24
  warnings = acceptor.warnings
@@ -37,10 +32,10 @@ class Puppet::Pops::IssueReporter
37
32
  # deprecation of constructs in manifests! (It is not designed for that purpose even if
38
33
  # used throughout the code base).
39
34
  #
40
- Puppet.warning(formatter.format(w)) if emitted_dw < max_deprecations
35
+ log_message(:warning, formatter, w) if emitted_dw < max_deprecations
41
36
  emitted_dw += 1
42
37
  else
43
- Puppet.warning(formatter.format(w)) if emitted_w < max_warnings
38
+ log_message(:warning, formatter, w) if emitted_w < max_warnings
44
39
  emitted_w += 1
45
40
  end
46
41
  break if emitted_w >= max_warnings && emitted_dw >= max_deprecations # but only then
@@ -56,7 +51,7 @@ class Puppet::Pops::IssueReporter
56
51
  formatter = Puppet::Pops::Validation::DiagnosticFormatterPuppetStyle.new
57
52
  if errors.size == 1 || max_errors <= 1
58
53
  # raise immediately
59
- exception = emit_exception.new(format_with_prefix(emit_message, formatter.format(errors[0])))
54
+ exception = create_exception(emit_exception, emit_message, formatter, errors[0])
60
55
  # if an exception was given as cause, use it's backtrace instead of the one indicating "here"
61
56
  if errors[0].exception
62
57
  exception.set_backtrace(errors[0].exception.backtrace)
@@ -68,7 +63,7 @@ class Puppet::Pops::IssueReporter
68
63
  Puppet.err(emit_message)
69
64
  end
70
65
  errors.each do |e|
71
- Puppet.err(formatter.format(e))
66
+ log_message(:err, formatter, e)
72
67
  emitted += 1
73
68
  break if emitted >= max_errors
74
69
  end
@@ -84,4 +79,35 @@ class Puppet::Pops::IssueReporter
84
79
  return message unless prefix
85
80
  [prefix, message].join(' ')
86
81
  end
82
+
83
+ def self.create_exception(exception_class, emit_message, formatter, diagnostic)
84
+ file = diagnostic.file
85
+ file = (file.is_a?(String) && file.empty?) ? nil : file
86
+ line = pos = nil
87
+ if diagnostic.source_pos
88
+ line = diagnostic.source_pos.line
89
+ pos = diagnostic.source_pos.pos
90
+ end
91
+ exception_class.new(format_with_prefix(emit_message, formatter.format_message(diagnostic)), file, line, pos, nil, diagnostic.issue.issue_code)
92
+ end
93
+ private_class_method :create_exception
94
+
95
+ def self.log_message(severity, formatter, diagnostic)
96
+ file = diagnostic.file
97
+ file = (file.is_a?(String) && file.empty?) ? nil : file
98
+ line = pos = nil
99
+ if diagnostic.source_pos
100
+ line = diagnostic.source_pos.line
101
+ pos = diagnostic.source_pos.pos
102
+ end
103
+ Puppet::Util::Log.create({
104
+ :level => severity,
105
+ :message => formatter.format_message(diagnostic),
106
+ :issue_code => diagnostic.issue.issue_code,
107
+ :file => file,
108
+ :line => line,
109
+ :pos => pos,
110
+ })
111
+ end
112
+ private_class_method :log_message
87
113
  end
@@ -374,6 +374,10 @@ module Puppet::Pops::Issues
374
374
  "#{label.a_an_uc(left_value)}[] cannot use #{actual} where #{expected_text} expected"
375
375
  end
376
376
 
377
+ BAD_NOT_UNDEF_SLICE_TYPE = issue :BAD_NOT_UNDEF_SLICE_TYPE, :base_type, :actual do
378
+ "#{base_type}[] argument must be a Type or a String. Got #{actual}"
379
+ end
380
+
377
381
  BAD_TYPE_SLICE_TYPE = issue :BAD_TYPE_SLICE_TYPE, :base_type, :actual do
378
382
  "#{base_type}[] arguments must be types. Got #{actual}"
379
383
  end
@@ -545,4 +549,96 @@ module Puppet::Pops::Issues
545
549
  MULTIPLE_ATTRIBUTES_UNFOLD = hard_issue :MULTIPLE_ATTRIBUTES_UNFOLD do
546
550
  "Unfolding of attributes from Hash can only be used once per resource body"
547
551
  end
552
+
553
+ SYNTAX_ERROR = hard_issue :SYNTAX_ERROR, :where do
554
+ "Syntax error at #{where}"
555
+ end
556
+
557
+ ILLEGAL_CLASS_REFERENCE = hard_issue :ILLEGAL_CLASS_REFERENCE do
558
+ 'Illegal class reference'
559
+ end
560
+
561
+ ILLEGAL_FULLY_QUALIFIED_CLASS_REFERENCE = hard_issue :ILLEGAL_FULLY_QUALIFIED_CLASS_REFERENCE do
562
+ 'Illegal fully qualified class reference'
563
+ end
564
+
565
+ ILLEGAL_FULLY_QUALIFIED_NAME = hard_issue :ILLEGAL_FULLY_QUALIFIED_NAME do
566
+ 'Illegal fully qualified name'
567
+ end
568
+
569
+ ILLEGAL_NAME_OR_BARE_WORD = hard_issue :ILLEGAL_NAME_OR_BARE_WORD do
570
+ 'Illegal name or bare word'
571
+ end
572
+
573
+ ILLEGAL_NUMBER = hard_issue :ILLEGAL_NUMBER do
574
+ 'Illegal number'
575
+ end
576
+
577
+ ILLEGAL_UNICODE_ESCAPE = issue :ILLEGAL_UNICODE_ESCAPE do
578
+ "Unicode escape '\\u' was not followed by 4 hex digits or 1-6 hex digits in {} or was > 10ffff"
579
+ end
580
+
581
+ INVALID_HEX_NUMBER = hard_issue :INVALID_HEX_NUMBER, :value do
582
+ "Not a valid hex number #{value}"
583
+ end
584
+
585
+ INVALID_OCTAL_NUMBER = hard_issue :INVALID_OCTAL_NUMBER, :value do
586
+ "Not a valid octal number #{value}"
587
+ end
588
+
589
+ INVALID_DECIMAL_NUMBER = hard_issue :INVALID_DECIMAL_NUMBER, :value do
590
+ "Not a valid decimal number #{value}"
591
+ end
592
+
593
+ NO_INPUT_TO_LEXER = hard_issue :NO_INPUT_TO_LEXER do
594
+ "Internal Error: No string or file given to lexer to process."
595
+ end
596
+
597
+ UNRECOGNIZED_ESCAPE = issue :UNRECOGNIZED_ESCAPE, :ch do
598
+ "Unrecognized escape sequence '\\#{ch}'"
599
+ end
600
+
601
+ UNCLOSED_QUOTE = hard_issue :UNCLOSED_QUOTE, :after, :followed_by do
602
+ "Unclosed quote after #{after} followed by '#{followed_by}'"
603
+ end
604
+
605
+ EPP_INTERNAL_ERROR = hard_issue :EPP_INTERNAL_ERROR, :error do
606
+ "Internal error: #{error}"
607
+ end
608
+
609
+ EPP_UNBALANCED_TAG = hard_issue :EPP_UNBALANCED_TAG do
610
+ 'Unbalanced epp tag, reached <eof> without closing tag.'
611
+ end
612
+
613
+ EPP_UNBALANCED_COMMENT = hard_issue :EPP_UNBALANCED_COMMENT do
614
+ 'Reaching end after opening <%# without seeing %>'
615
+ end
616
+
617
+ EPP_UNBALANCED_EXPRESSION = hard_issue :EPP_UNBALANCED_EXPRESSION do
618
+ 'Unbalanced embedded expression - opening <% and reaching end of input'
619
+ end
620
+
621
+ HEREDOC_UNCLOSED_PARENTHESIS = hard_issue :HEREDOC_UNCLOSED_PARENTHESIS, :followed_by do
622
+ "Unclosed parenthesis after '@(' followed by '#{followed_by}'"
623
+ end
624
+
625
+ HEREDOC_WITHOUT_END_TAGGED_LINE = hard_issue :HEREDOC_WITHOUT_END_TAGGED_LINE do
626
+ 'Heredoc without end-tagged line'
627
+ end
628
+
629
+ HEREDOC_INVALID_ESCAPE = hard_issue :HEREDOC_INVALID_ESCAPE, :actual do
630
+ "Invalid heredoc escape char. Only t, r, n, s, u, L, $ allowed. Got '#{actual}'"
631
+ end
632
+
633
+ HEREDOC_INVALID_SYNTAX = hard_issue :HEREDOC_INVALID_SYNTAX do
634
+ 'Invalid syntax in heredoc expected @(endtag[:syntax][/escapes])'
635
+ end
636
+
637
+ HEREDOC_WITHOUT_TEXT = hard_issue :HEREDOC_WITHOUT_TEXT do
638
+ 'Heredoc without any following lines of text'
639
+ end
640
+
641
+ HEREDOC_MULTIPLE_AT_ESCAPES = hard_issue :HEREDOC_MULTIPLE_AT_ESCAPES, :escapes do
642
+ "An escape char for @() may only appear once. Got '#{escapes.join(', ')}'"
643
+ end
548
644
  end
@@ -175,7 +175,9 @@ module Puppet::Pops::Loader::ModuleLoaders
175
175
  # Produces the private loader for the module. If this module is not already resolved, this will trigger resolution
176
176
  #
177
177
  def private_loader
178
- @private_loader ||= @loaders.private_loader_for_module(module_name)
178
+ # The system loader has a nil module_name and it does not have a private_loader as there are no functions
179
+ # that can only by called by puppet runtime - if so, it acts as the privuate loader directly.
180
+ @private_loader ||= ((module_name.nil? && self) || @loaders.private_loader_for_module(module_name))
179
181
  end
180
182
  end
181
183
 
@@ -12,9 +12,11 @@ class Puppet::Pops::Loaders
12
12
 
13
13
  # Create the set of loaders
14
14
  # 1. Puppet, loads from the "running" puppet - i.e. bundled functions, types, extension points and extensions
15
- # Does not change without rebooting the service running puppet.
15
+ # These cannot be cached since a loaded instance will be bound to its closure scope which holds on to
16
+ # a compiler and all loaded types. Subsequent request would find remains of the environment that loaded
17
+ # the content. PUP-4461.
16
18
  #
17
- @@puppet_system_loader ||= create_puppet_system_loader()
19
+ @puppet_system_loader = create_puppet_system_loader()
18
20
 
19
21
  # 2. Environment loader - i.e. what is bound across the environment, may change for each setup
20
22
  # TODO: loaders need to work when also running in an agent doing catalog application. There is no
@@ -30,7 +32,7 @@ class Puppet::Pops::Loaders
30
32
  #
31
33
  def self.clear
32
34
  @@static_loader = nil
33
- @@puppet_system_loader = nil
35
+ @puppet_system_loader = nil
34
36
  end
35
37
 
36
38
  def static_loader
@@ -38,7 +40,7 @@ class Puppet::Pops::Loaders
38
40
  end
39
41
 
40
42
  def puppet_system_loader
41
- @@puppet_system_loader
43
+ @puppet_system_loader
42
44
  end
43
45
 
44
46
  def public_loader_for_module(module_name)
@@ -0,0 +1,45 @@
1
+ # This class defines the private API of the MigrationChecker support.
2
+ # @api private
3
+ #
4
+ class Puppet::Pops::Migration::MigrationChecker
5
+
6
+ def initialize()
7
+ end
8
+
9
+ # Produces a hash of available migrations; a map from a symbolic name in string form to a brief description.
10
+ def available_migrations()
11
+ { '3.8/4.0' => '3.8 future parser to 4.0 language migrations'}
12
+ end
13
+
14
+ # For 3.8/4.0
15
+ def report_ambiguous_integer(o)
16
+ end
17
+
18
+ # For 3.8/4.0
19
+ def report_ambiguous_float(o)
20
+ end
21
+
22
+ # For 3.8/4.0
23
+ def report_empty_string_true(value, o)
24
+ end
25
+
26
+ # For 3.8/4.0
27
+ def report_uc_bareword_type(value, o)
28
+ end
29
+
30
+ # For 3.8/4.0
31
+ def report_equality_type_mismatch(left, right, o)
32
+ end
33
+
34
+ # For 3.8/4.0
35
+ def report_option_type_mismatch(test_value, option_value, option_expr, matching_expr)
36
+ end
37
+
38
+ # For 3.8/4.0
39
+ def report_in_expression(o)
40
+ end
41
+
42
+ # For 3.8/4.0
43
+ def report_array_last_in_block(o)
44
+ end
45
+ end
@@ -773,7 +773,7 @@ class Puppet::Pops::Model::Factory
773
773
  'info' => true,
774
774
  'notice' => true,
775
775
  'warning' => true,
776
- 'error' => true,
776
+ 'err' => true,
777
777
 
778
778
  'fail' => true,
779
779
  'import' => true # discontinued, but transform it to make it call error reporting function
@@ -258,7 +258,7 @@ module Puppet::Pops::Model
258
258
  class CollectExpression < Expression
259
259
  contains_one_uni 'type_expr', Expression, :lowerBound => 1
260
260
  contains_one_uni 'query', QueryExpression, :lowerBound => 1
261
- contains_many_uni 'operations', AttributeOperation
261
+ contains_many_uni 'operations', AbstractAttributeOperation
262
262
  end
263
263
 
264
264
  class Parameter < Positioned
@@ -354,7 +354,7 @@ unless_expression
354
354
  loc result, val[0], val[4]
355
355
  }
356
356
  | UNLESS expression LBRACE RBRACE unless_else {
357
- result = Factory.UNLESS(val[1], nil, nil)
357
+ result = Factory.UNLESS(val[1], nil, val[4])
358
358
  loc result, val[0], val[4]
359
359
  }
360
360
 
@@ -1927,7 +1927,7 @@ module_eval(<<'.,.,', 'egrammar.ra', 352)
1927
1927
 
1928
1928
  module_eval(<<'.,.,', 'egrammar.ra', 356)
1929
1929
  def _reduce_105(val, _values, result)
1930
- result = Factory.UNLESS(val[1], nil, nil)
1930
+ result = Factory.UNLESS(val[1], nil, val[4])
1931
1931
  loc result, val[0], val[4]
1932
1932
 
1933
1933
  result
@@ -33,7 +33,7 @@ module Puppet::Pops::Parser::EppSupport
33
33
  ctx = @lexing_context
34
34
  queue = @token_queue
35
35
 
36
- lex_error "Internal Error: No string or file given to lexer to process." unless scn
36
+ lex_error(Puppet::Pops::Issues::EPP_INTERNAL_ERROR, :error => 'No string or file given to lexer to process.') unless scn
37
37
 
38
38
  ctx[:epp_mode] = :text
39
39
  enqueue_completed([:EPP_START, nil, 0], 0)
@@ -47,7 +47,7 @@ module Puppet::Pops::Parser::EppSupport
47
47
  end
48
48
  end
49
49
  if ctx[:epp_open_position]
50
- lex_error("Unbalanced epp tag, reached <eof> without closing tag.", ctx[:epp_position])
50
+ lex_error(Puppet::Pops::Issues::EPP_UNBALANCED_TAG, {}, ctx[:epp_position])
51
51
  end
52
52
 
53
53
  # Signals end of input
@@ -65,7 +65,9 @@ module Puppet::Pops::Parser::EppSupport
65
65
  case eppscanner.mode
66
66
  when :text
67
67
  # Should be at end of scan, or something is terribly wrong
68
- lex_error("Internal error: template scanner returns text mode and is not and end of input") unless @scanner.eos?
68
+ unless @scanner.eos?
69
+ lex_error(Puppet::Pops::Issues::EPP_INTERNAL_ERROR, :error => 'template scanner returns text mode and is not and end of input')
70
+ end
69
71
  if s
70
72
  # s may be nil if scanned text ends with an epp tag (i.e. no trailing text).
71
73
  enqueue_completed([:RENDER_STRING, s, scn.pos - before], before)
@@ -74,7 +76,7 @@ module Puppet::Pops::Parser::EppSupport
74
76
  # do nothing else, scanner is at the end
75
77
 
76
78
  when :error
77
- lex_error(eppscanner.message())
79
+ lex_error(eppscanner.issue)
78
80
 
79
81
  when :epp
80
82
  # It is meaningless to render empty string segments, and it is harmful to do this at
@@ -97,7 +99,7 @@ module Puppet::Pops::Parser::EppSupport
97
99
  ctx[:epp_mode] = :expr
98
100
  ctx[:epp_open_position] = scn.pos
99
101
  else
100
- lex_error("Internal Error, Unknown mode #{eppscanner.mode} returned by template scanner")
102
+ lex_error(Puppet::Pops::Issues::EPP_INTERNAL_ERROR, :error => "Unknown mode #{eppscanner.mode} returned by template scanner")
101
103
  end
102
104
  nil
103
105
  end
@@ -144,8 +146,8 @@ module Puppet::Pops::Parser::EppSupport
144
146
  #
145
147
  attr_reader :mode
146
148
 
147
- # An error message if `mode == :error`, `nil` otherwise.
148
- attr_reader :message
149
+ # An error issue if `mode == :error`, `nil` otherwise.
150
+ attr_reader :issue
149
151
 
150
152
  # If the first scan should skip leading whitespace (typically detected by the pp lexer when the
151
153
  # pp mode end-token is found (i.e. `-%>`) and then passed on to the scanner.
@@ -159,6 +161,13 @@ module Puppet::Pops::Parser::EppSupport
159
161
  @scanner = scanner
160
162
  end
161
163
 
164
+ # Here for backwards compatibility.
165
+ # @deprecated Use issue instead
166
+ # @return [String] the issue message
167
+ def message
168
+ @issue.nil? ? nil : @issue.format
169
+ end
170
+
162
171
  # Scans from the current position in the configured scanner, advances this scanner's position until the end
163
172
  # of the input, or to the first position after a mode switching token (`<%`, `<%-` or `<%=`). Number of processed
164
173
  # lines and continuation mode can be obtained via {#lines}, and {#mode}.
@@ -189,7 +198,7 @@ module Puppet::Pops::Parser::EppSupport
189
198
  # if s ends with <% then this is an error (unbalanced <% %>)
190
199
  if s.end_with? "<%"
191
200
  @mode = :error
192
- @message = "Unbalanced embedded expression - opening <% and reaching end of input"
201
+ @issue = Puppet::Pops::Issues::EPP_UNBALANCED_EXPRESSION
193
202
  else
194
203
  mode = :epp
195
204
  end
@@ -227,7 +236,7 @@ module Puppet::Pops::Parser::EppSupport
227
236
  # preceded by a % (i.e. skip %%>)
228
237
  part = scanner.scan_until(/[^%]%>/)
229
238
  unless part
230
- @message = "Reaching end after opening <%# without seeing %>"
239
+ @issue = Puppet::Pops::Issues::EPP_UNBALANCED_COMMENT
231
240
  @mode = :error
232
241
  return s
233
242
  end