diff options
| author | Alasdair Armstrong | 2018-04-19 15:13:10 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2018-04-19 15:18:23 +0100 |
| commit | b93ae6094a95e3bfaed9196f396ea72d3d66ea74 (patch) | |
| tree | f423d30be64b4428f7a1188d515383f43248d793 | |
| parent | 725d5d7868b3b10882ee6eb2fa2f3e63212c1848 (diff) | |
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.
| -rw-r--r-- | src/initial_check.ml | 3 | ||||
| -rw-r--r-- | test/typecheck/pass/option_tuple.sail | 11 |
2 files changed, 12 insertions, 2 deletions
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 |
