Simon Génier pushed to branch gambit at Stefan / Typer
Commits: 0ea08dd8 by Simon Génier at 2021-03-14T21:38:07-04:00 [Gambit] Do new generate new var for the target when it is a variable.
- - - - -
1 changed file:
- src/gambit.ml
Changes:
===================================== src/gambit.ml ===================================== @@ -199,7 +199,11 @@ let rec scheme_of_expr (sctx : ScmContext.t) (elexp : elexp) : Scm.t = make_curried_lambda vars vector_expr
| Elexp.Case (_, target, branches, default_branch) - -> let target_name = Scm.Symbol (gensym "target") in + -> let target_name = + match target with + | Elexp.Var _ -> scheme_of_expr sctx target + | _ -> Scm.Symbol (gensym "target") + in let scm_default_branch = match default_branch with | None -> [] @@ -247,9 +251,13 @@ let rec scheme_of_expr (sctx : ScmContext.t) (elexp : elexp) : Scm.t = Scm.Integer Z.zero] :: scm_branches) in - Scm.List [Scm.let'; - Scm.List [Scm.List [target_name; scheme_of_expr sctx target]]; - scm_case] + (match target with + | Elexp.Var _ -> scm_case + | _ + -> Scm.List [Scm.let'; + Scm.List [Scm.List [target_name; + scheme_of_expr sctx target]]; + scm_case])
| Elexp.Type _ -> Scm.Symbol "lets-hope-its-ok-if-i-erase-this"
View it on GitLab: https://gitlab.com/monnier/typer/-/commit/0ea08dd805eb30bc45e0977ce3ba2de300...
Afficher les réponses par date