hashicorp / hcl2

Former temporary home for experimental new version of HCL
https://github.com/hashicorp/hcl
Mozilla Public License 2.0
373 stars 66 forks source link

Incorrect error message for type mismatch in conditionals #40

Closed apparentlymart closed 5 years ago

apparentlymart commented 6 years ago

The error message for a conditional expression type mismatch uses a direct string representation of the types, rather than calling the FriendlyName method on those types to get the user-facing name:

https://github.com/hashicorp/hcl2/blob/6558d83419b8415adbcc4df88fd6c8b56fbbaf5f/hcl/hclsyntax/expression.go#L458-L473

As a result, the detail message is useless:

The true and false result expressions must have consistent types. The given
expressions are {{{} [{{{} %!s(cty.primitiveTypeKind=83)}}]}} and {{{}
%!s(cty.primitiveTypeKind=83)}}, respectively.
apparentlymart commented 5 years ago

This was fixed in 8dd89ebbb39f962067b1c5e57b03a1dd80c3857a.