code: func (an *analysis) InferExpressionType(src []byte, self addrs.Referenceable) cty.Type {
  	expr, diags := hcl2syntax.ParseExpression(src, "", hcl2.Pos{Line: 1, Column: 1})
  	if diags.HasErrors() {
  		// If there's a syntax error then analysis is impossible.
  		return cty.DynamicPseudoType
  	}
  
  	data := analysisData{an}
  	scope := &lang.Scope{
  		Data:     data,
  		SelfAddr: self,
  		PureOnly: false,
  		BaseDir:  ".",
  	}
  	val, _ := scope.EvalExpr(expr, cty.DynamicPseudoType)
  
  	// Value will be cty.DynamicVal if either inference was impossible or
  	// if there was an error, leading to cty.DynamicPseudoType here.
  	return val.Type()
  }
docs: // InferExpressionType attempts to determine a result type for the given
  // expression source code, which should already have been upgraded to new
  // expression syntax.
  //
  // If self is non-nil, it will determine the meaning of the special "self"
  // reference.
  //
  // If such an inference isn't possible, either because of limitations of
  // static analysis or because of errors in the expression, the result is
  // cty.DynamicPseudoType indicating "unknown".