func checkVarType()

in interfaces/interface_variable.go [182:197]


func checkVarType(vcr *InterfaceVarCheckRule, r tflint.Runner, typeAttr *hclext.Attribute) func() (bool, error) {
	return func() (bool, error) {
		// Check if the type interface is correct.
		gotType, diags := varcheck.NewTypeConstraintWithDefaultsFromExp(typeAttr.Expr)
		if diags.HasErrors() {
			return false, diags
		}
		if eq := check.EqualTypeConstraints(gotType, vcr.TypeConstraintWithDefs); !eq {
			return true, r.EmitIssue(vcr,
				fmt.Sprintf("variable type does not comply with the interface specification:\n\n%s", vcr.VarTypeString),
				typeAttr.Range,
			)
		}
		return true, nil
	}
}