Skip to content

Commit

Permalink
Finished type checking. Committing pending rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ibdafna committed Aug 5, 2022
1 parent 095b604 commit 1712558
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 35 deletions.
3 changes: 2 additions & 1 deletion compiler/src/formatting/debug.re
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ let debug_expression = (expr: Parsetree.expression) => {
| PExpLambda(patterns, expression) =>
print_loc("PExpLambda", expr.pexp_loc)
| PExpApp(func, expressions) => print_loc("PExpApp", expr.pexp_loc)
| PExpConstruct(func, expression) => print_loc("PExpConstruct", expr.pexp_loc)
| PExpConstruct(func, expression) =>
print_loc("PExpConstruct", expr.pexp_loc)
| PExpBlock(expressions) => print_loc("PExpBlock", expr.pexp_loc)
| PExpBoxAssign(expression, expression1) =>
print_loc("PExpBoxAssign", expr.pexp_loc)
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/parsing/ast_iterator.re
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ module E = {
| PExpApp(e, el) =>
sub.expr(sub, e);
List.iter(sub.expr(sub), el);
| PExpConstruct(c, el) =>
iter_ident(sub, c);
List.iter(sub.expr(sub), el);
| PExpBlock(el) => List.iter(sub.expr(sub), el)
| PExpNull => ()
};
Expand Down
36 changes: 2 additions & 34 deletions compiler/src/typed/typecore.re
Original file line number Diff line number Diff line change
Expand Up @@ -935,30 +935,8 @@ and type_expect_ =
exp_type: ty_res,
exp_env: env,
});
| PExpConstruct(func, args) =>
begin_def();
if (Grain_utils.Config.principal^) {
begin_def();
};
let funct = type_exp(env, func);
if (Grain_utils.Config.principal^) {
end_def();
generalize_structure(funct.exp_type);
};
end_def();
/*lower_args [] ty;*/
begin_def();
let (args, ty_res) = type_construct(env, funct, args);
end_def();
unify_var(env, newvar(), funct.exp_type);
rue({
exp_desc: TExpConstruct(funct, args),
exp_loc: loc,
exp_extra: [],
exp_attributes: attributes,
exp_type: ty_res,
exp_env: env,
});
| PExpConstruct(cstr, args) =>
type_construct(env, loc, cstr, args, ty_expected_explained, attributes)
| PExpMatch(arg, branches) =>
begin_def();
let arg = type_exp(env, arg);
Expand Down Expand Up @@ -1423,7 +1401,6 @@ and type_construct = (env, loc, lid, sargs, ty_expected_explained, attrs) => {
}) {
| Not_found => None
};

let constrs = Typetexp.find_all_constructors(env, lid.loc, lid.txt);
let constr =
wrap_disambiguate(
Expand All @@ -1432,15 +1409,6 @@ and type_construct = (env, loc, lid, sargs, ty_expected_explained, attrs) => {
Constructor.disambiguate(lid, env, opath),
constrs,
);
/*Env.mark_constructor Env.Positive env (Identifier.last lid.txt) constr;*/
/* let sargs =
switch (sarg) {
| None => []
| Some({pexp_desc: PExpTuple(sel)}) when constr.cstr_arity > 1 =>
/*|| Builtin_attributes.explicit_arity attrs*/
sel
| Some(se) => [se]
}; */
if (List.length(sargs) != constr.cstr_arity) {
raise(
Error(
Expand Down

0 comments on commit 1712558

Please sign in to comment.