From b93ae6094a95e3bfaed9196f396ea72d3d66ea74 Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Thu, 19 Apr 2018 15:13:10 +0100 Subject: Fix bug with function being applied to tuples For some reason there was a desugaring rule that mapped f((x, y)) to f(x, y) in initial_check.ml, this prevented functions and constructors from being applied to tuples. --- src/initial_check.ml | 3 +-- test/typecheck/pass/option_tuple.sail | 11 +++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/typecheck/pass/option_tuple.sail diff --git a/src/initial_check.ml b/src/initial_check.ml index c6bc5fbe..62c1af02 100644 --- a/src/initial_check.ml +++ b/src/initial_check.ml @@ -493,8 +493,7 @@ and to_ast_exp (k_env : kind Envmap.t) (def_ord : order) (Parse_ast.E_aux(exp,l) | Parse_ast.E_app(f,args) -> (match List.map (to_ast_exp k_env def_ord) args with | [] -> E_app(to_ast_id f, []) - | [E_aux(E_tuple(exps),_)] -> E_app(to_ast_id f, exps) - | exps -> E_app(to_ast_id f, exps)) + | exps -> E_app(to_ast_id f, exps)) | Parse_ast.E_app_infix(left,op,right) -> E_app_infix(to_ast_exp k_env def_ord left, to_ast_id op, to_ast_exp k_env def_ord right) | Parse_ast.E_tuple(exps) -> E_tuple(List.map (to_ast_exp k_env def_ord) exps) diff --git a/test/typecheck/pass/option_tuple.sail b/test/typecheck/pass/option_tuple.sail new file mode 100644 index 00000000..f89bb080 --- /dev/null +++ b/test/typecheck/pass/option_tuple.sail @@ -0,0 +1,11 @@ +union option ('a : Type) = {None : unit, Some : 'a} + +function gen() -> option(nat) = None() + +function wrap_broken() -> option((nat, nat)) = { + match (gen()) { + Some(i) => let r = (i, i) in Some(r), /* works */ + Some(i) => Some((i, i)), /* doesn't work */ + None() => None() + } +} \ No newline at end of file -- cgit v1.2.3