(maint) undef not correctly handled in type calculator#2194
Merged
hlindberg merged 5 commits intopuppetlabs:masterfrom Dec 28, 2013
Merged
Conversation
To be able to more easily deal with undef (not matched by default except by Data) the convenience type Optional is introduced with the same semantics as Variant[T, Undef] (i.e. undef/nil) is accepted instead of real type).
instace? should not return true for undef for all types. This means that [undef] =~ Array[Integer] is false. The Data type was relaxed to still accept undef/nil everywhere except as a key in a hash.
Since types are now restrictive, the injector must tolerate undef as instance (i.e. since it means 'not found').
The type system implementation and tests had several flaws. * Tests did not call expect/should and did not assert * Undef handled wrong wrt. instance_of * String allowed parameterization with string values (useless). Can now instead be parameterized with a size constraint * Collection, Array, and Hash can now be parameterized with size constraint. * Data type made lenient allowing undef in constructs
|
CLA signed by all contributors. |
hlindberg
added a commit
that referenced
this pull request
Dec 28, 2013
…dled-in-type-calculator (maint) undef not correctly handled in type calculator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There were several problems wrt. undef in the implementation of handling undef in the type calculator (aka
the type system). Some of this was due to faulty tests (never called expect/should) and problems went unnoticed.
While making the handling of undef sane it was also needed to offer an Optional type, and to handle the
kind of undefinedness that occurs when an array or hash is empty. (This was also generalized to handle String which
had non-meaningful behavior allowing users to parameterize a String with a set of string value (which is only meaningful to the type inference)).