Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional attributes fixes #88

Merged
merged 3 commits into from
Mar 8, 2021

Commits on Mar 4, 2021

  1. convert: Fix for null objects with optional attrs

    Conversions targeting types which are or include objects with optional
    attributes always simplify those types, removing the optional attributes
    from the type, and inserting null values for any that are missing.
    Objects with optional attributes are not intended to be used to
    instantiate values.
    
    One accidental exception to this was the null value of dynamic type.
    These values are passed through by the getConversion wrapper, assigning
    the desired type. This conflicts with the type simplification rules for
    non-null values, and can result in a panic when a collection type
    contains null values.
    
    This commit fixes this at the wrapper level by performing the same type
    simplification when converting null into an object type.
    alisdair committed Mar 4, 2021
    Configuration menu
    Copy the full SHA
    9f8e9d3 View commit details
    Browse the repository at this point in the history
  2. convert: Fix unification of collection values

    To correctly unify deep nested types, we need to unify all collection
    types (maps, lists, sets), not just maps. This ensures that all cousin
    types are unified correctly.
    
    This problem was first addressed for maps in zclconf#47 a year ago, but we
    didn't realize at the time that the same bug could manifest in other
    collection types.
    alisdair committed Mar 4, 2021
    Configuration menu
    Copy the full SHA
    6b02a10 View commit details
    Browse the repository at this point in the history

Commits on Mar 8, 2021

  1. convert: Recursively concretize unknown/null

    When converting unknown and null values to a given type, we want to
    avoid constructing instances of types which include optional object
    attributes, even deeply nested. To do this we add a new method,
    cty.Type.WithoutOptionalAttributesDeep, which recursively processes its
    receiver to return a type which has no instances of objects with
    optional attributes.
    alisdair committed Mar 8, 2021
    Configuration menu
    Copy the full SHA
    dfcbf96 View commit details
    Browse the repository at this point in the history