Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-5964

Improve how type mismatches are asserted and reported



    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • PUP 4.4.0
    • None
    • None
    • 2
    • Language 2016-02-24, Language 2016-03-09, Language 2016-03-23
    • New Feature
    • The error message generated from the function asssert_type is now of the same high quality as the message produced for automatically type checked parameters.


      Type assertion and reporting could be greatly improved and also made consistent by fixing three minor things.

      1. The TypeAsserter methods takes a subject parameter that explains in what context the assertion takes place. It is often desirable to create this subject string from things in that context (i.e. format a string). Formatting strings that may or may not be used is however not a good practice since the formatting itself is resource consuming. Deferred formatting can be enabled by a) allowing an Array argument where the first element is a format string and the remaining elements are parameters to that format string, and b) allowing a block to be passed in the calls to the TypeAsserter. The block is called with the subject parameter as it's argument and returns a new subject.
      2. The TypeAsserter currently creates it's own "type mismatch" based on the subject and the compared types. It should instead utilize the TypeMismatchDescriber
      3. The Puppet function assert_type has it's own logic for asserting and printing errors. It should use the TypeAsserter.


        Issue Links



              Unassigned Unassigned
              thomas.hallgren Thomas Hallgren
              0 Vote for this issue
              3 Start watching this issue



                Zendesk Support