Skip to content

(maint) undef not correctly handled in type calculator#2194

Merged
hlindberg merged 5 commits intopuppetlabs:masterfrom
hlindberg:maint_undef-not-correctly-handled-in-type-calculator
Dec 28, 2013
Merged

(maint) undef not correctly handled in type calculator#2194
hlindberg merged 5 commits intopuppetlabs:masterfrom
hlindberg:maint_undef-not-correctly-handled-in-type-calculator

Conversation

@hlindberg
Copy link
Contributor

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)).

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
@puppetcla
Copy link

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
@hlindberg hlindberg merged commit 9901653 into puppetlabs:master Dec 28, 2013
@hlindberg hlindberg deleted the maint_undef-not-correctly-handled-in-type-calculator branch December 28, 2013 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants