opentofu/internal/lang/funcs
Martin Atkins d4776e8ef1 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.
2022-04-20 09:09:12 -07:00
..
testdata lang: Redact sensitive values from function errors 2021-12-03 09:46:57 -05:00
cidr_test.go cidrnetmask() produce an error with IPv6 (#30703) 2022-03-25 14:26:47 +00:00
cidr.go cidrnetmask() produce an error with IPv6 (#30703) 2022-03-25 14:26:47 +00:00
collection_test.go functions: Fix sum() of all strings 2022-03-16 08:50:06 -04:00
collection.go functions: Fix sum() of all strings 2022-03-16 08:50:06 -04:00
conversion_test.go lang/funcs: type conversion functions can convert null values 2022-04-20 09:09:12 -07:00
conversion.go lang/funcs: type conversion functions can convert null values 2022-04-20 09:09:12 -07:00
crypto_test.go Move lang/ to internal/lang/ 2021-05-17 14:09:07 -07:00
crypto.go funcs: defer close file in funcs 2021-11-16 09:25:49 +01:00
datetime_test.go Move lang/ to internal/lang/ 2021-05-17 14:09:07 -07:00
datetime.go Move lang/ to internal/lang/ 2021-05-17 14:09:07 -07:00
defaults_test.go Move lang/ to internal/lang/ 2021-05-17 14:09:07 -07:00
defaults.go Move lang/ to internal/lang/ 2021-05-17 14:09:07 -07:00
encoding_test.go lang: Redact sensitive values from function errors 2021-12-03 09:46:57 -05:00
encoding.go lang: Redact sensitive values from function errors 2021-12-03 09:46:57 -05:00
filesystem_test.go lang/funcs: fileexists slightly better "not a file" error message 2022-01-11 08:46:29 -08:00
filesystem.go lang/funcs: fileexists slightly better "not a file" error message 2022-01-11 08:46:29 -08:00
number_test.go lang: Remove use of marks.Raw in tests 2022-02-09 17:43:54 -05:00
number.go lang: Redact sensitive values from function errors 2021-12-03 09:46:57 -05:00
redact_test.go lang: Remove use of marks.Raw in tests 2022-02-09 17:43:54 -05:00
redact.go lang: Redact sensitive values from function errors 2021-12-03 09:46:57 -05:00
sensitive_test.go update to use typed sensitive marks 2021-06-25 12:49:07 -04:00
sensitive.go marks package 2021-06-25 12:35:51 -04:00
string_test.go Move lang/ to internal/lang/ 2021-05-17 14:09:07 -07:00
string.go Move lang/ to internal/lang/ 2021-05-17 14:09:07 -07:00