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

convert: Type information lost when converting unknown value to DynamicPseudoType #13

Closed
apparentlymart opened this issue Dec 6, 2018 · 1 comment
Labels
bug convert Type conversions

Comments

@apparentlymart
Copy link
Collaborator

The intended meaning of a conversion to DynamicPseudoType is to take no conversion action whatsoever and just return the given value verbatim.

This works for known values, but due to a special case for unknown values does not behave as expected for those:

if !in.IsKnown() {
return cty.UnknownVal(out), nil
}

This is correct behavior when the output type is known, since the conversion type selection logic already proved that a conversion between the in and out types is valid, but if the output type is DynamicPseudoType this causes the result to be DynamicVal, losing the original type information in the unknown value.

Instead, we should treat DynamicPseudoType as a further special case and just return the given unknown value verbatim if that is selected as the output type.

(Converting to dynamic is a strange thing to do specifically, but this behavior is intended as a convenience for callers that are doing a conversion on behalf of a transitive caller that is specifying a target type, so that such intermediate callers don't need to themselves handle this as a special case.)

@apparentlymart
Copy link
Collaborator Author

This was fixed by 3a34021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug convert Type conversions
Projects
None yet
Development

No branches or pull requests

1 participant