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

ensure correct type in conditionals w/ DynamicVal #118

Closed jbardin closed 4 years ago

jbardin commented 4 years ago

If an expression in a conditional contains a DynamicVal, we know that the opposing condition can pass through with no conversion since converting to a DynamicPseudoType is a noop. We can also just pass through the Dynamic val, since it is unknown and can't be converted.

codecov-io commented 4 years ago

Codecov Report

Merging #118 into master will increase coverage by 0.02%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #118      +/-   ##
=========================================
+ Coverage   68.98%     69%   +0.02%     
=========================================
  Files          98      98              
  Lines       10323   10324       +1     
=========================================
+ Hits         7121    7124       +3     
+ Misses       2873    2871       -2     
  Partials      329     329
Impacted Files Coverage Δ
hcl/hclsyntax/expression.go 62.9% <100%> (+0.27%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5b39d9f...c899efe. Read the comment docs.

jbardin commented 4 years ago

While there might be room to improve the unification algorithm, after digging in to this, I think unify just wasn't quite the right tool for the expression as a whole. It still appears to be part of the solution, as the logic seems sound for cases where both values are known, but the unknown cases don't need unification, because they are disjoint.