Skip to content

type_check_expr vs type_check_expr_in - unify or not? #362

Open
@erszcz

Description

@erszcz

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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions