Open
Description
These two seem to be similar, but according to some comments here in issues and in the code they are significantly different.
The source code comments say:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% @doc Infer type of expression
%%
%% Type information should* stem from user type annotation (function specs
%% and type annotated record definitions). If an expression does not have a
%% subexpression that has a type inferred from these sources, its inferred type
%% will be `any()'.
%%
%% *) When the option 'infer' is true, the types of literals and other
%% constructs are also propagated.
%%
%% Arguments: An environment for functions, an environment for variables
%% and the expression to type check.
%% Returns the type of the expression, a collection of variables bound in
%% the expression together with their type and constraints.
-spec type_check_expr(env(), expr()) -> {any(), venv(), constraints:constraints()}.
type_check_expr(Env, Expr) ->
and
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Checking the type of an expression
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
type_check_expr_in(Env, ResTy, Expr) ->
As we can see already their names are a bit unfortunate, as _in
, at least to me, suggests inference, but it's exactly the other way around. Maybe it's for internal?
@zuiderkwast, I've found this comment - #337 (reply in thread) - mentioning that it might be worth merging these functions. In such a case, would we still want the infer
option to exist or would inference become the new default with no way to opt out of it?