diff options
| author | Alasdair Armstrong | 2017-08-01 17:38:17 +0100 |
|---|---|---|
| committer | Alasdair Armstrong | 2017-08-01 17:38:17 +0100 |
| commit | 3695b589eaf0bdf3cdb78cf0b26ba5f70f314dd3 (patch) | |
| tree | 7fed08c2ad3547c337259c5fb0f04d0342324d3f | |
| parent | a56ddf5b864c23be7c47dc84882b436b3a4f7473 (diff) | |
Fixed a bug where as patterns weren't binding their variable correctly
| -rw-r--r-- | src/type_check.ml | 2 | ||||
| -rw-r--r-- | test/typecheck/pass/as_pattern.sail | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/src/type_check.ml b/src/type_check.ml index 0a2c0dcb..87f65dcc 100644 --- a/src/type_check.ml +++ b/src/type_check.ml @@ -1968,7 +1968,7 @@ and infer_pat env (P_aux (pat_aux, (l, ())) as pat) = annot_pat (P_vector_concat (inferred_pat :: inferred_pats)) (lvector_typ env len vtyp), env | P_as (pat, id) -> let (typed_pat, env) = infer_pat env pat in - annot_pat (P_as (typed_pat, id)) (pat_typ_of typed_pat), env + annot_pat (P_as (typed_pat, id)) (pat_typ_of typed_pat), Env.add_local id (Immutable, pat_typ_of typed_pat) env | _ -> typ_error l ("Couldn't infer type of pattern " ^ string_of_pat pat) and bind_assignment env (LEXP_aux (lexp_aux, _) as lexp) (E_aux (_, (l, ())) as exp) = diff --git a/test/typecheck/pass/as_pattern.sail b/test/typecheck/pass/as_pattern.sail new file mode 100644 index 00000000..a1cd9461 --- /dev/null +++ b/test/typecheck/pass/as_pattern.sail @@ -0,0 +1,7 @@ + +val int -> int effect pure test + +function test ((int) _ as x) = +{ + x +} |
