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

lang/funcs: type conversion functions can convert null values #30879

Merged
merged 1 commit into from Apr 20, 2022

Commits on Apr 15, 2022

  1. lang/funcs: type conversion functions can convert null values

    We had intended these functions to attempt to convert any given value, but
    there is a special behavior in the function system where functions must
    opt in to being able to handle dynamically-typed arguments so that we
    don't need to repeat the special case for that inside every function
    implementation.
    
    In this case we _do_ want to specially handle dynamically-typed values,
    because the keyword "null" in HCL produces
    cty.NullVal(cty.DynamicPseudoType) and we want the conversion function
    to convert it to a null of a more specific type.
    
    These conversion functions are already just a thin wrapper around the
    underlying type conversion functionality anyway, and that already supports
    converting dynamic-typed values in the expected way, so we can just opt
    in to allowing dynamically-typed values and let the conversion
    functionality do the expected work.
    
    Fixing this allows module authors to use type conversion functions to
    give additional type information to Terraform in situations that are too
    ambiguous to be handled automatically by the type inference/unification
    process. Previously tostring(null) was effectively a no-op, totally
    ignoring the author's request to treat the null as a string.
    apparentlymart committed Apr 15, 2022
    Copy the full SHA
    2bfe3ac View commit details
    Browse the repository at this point in the history