From add73b7154a048a37d4eed7f3f245d00fd683879 Mon Sep 17 00:00:00 2001 From: John Sonchack Date: Tue, 21 Apr 2026 16:29:14 -0400 Subject: [PATCH 1/2] missed file --- .../frontend/transformations/RefreshTypes.ml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/lib/frontend/transformations/RefreshTypes.ml diff --git a/src/lib/frontend/transformations/RefreshTypes.ml b/src/lib/frontend/transformations/RefreshTypes.ml new file mode 100644 index 00000000..b3018383 --- /dev/null +++ b/src/lib/frontend/transformations/RefreshTypes.ml @@ -0,0 +1,37 @@ +(* Reset effect annotations on types inside handler and function bodies. + This is a temporary patch / hack for type checking to work in + certain phases of the frontend (from TableInlining to MonomorphicEventArgs), + After a typing pass, types in handler bodies carry resolved effects with + specific index variable IDs. These conflict with fresh variables created + by a subsequent typing pass. This pass replaces those teffect fields with + fresh effect variables, allowing a subsequent type checker to re-derive + effects from program structure. + + Top-level declarations (globals, events, user types) are left untouched + since their effects carry meaningful semantic information (e.g., global + ordering). *) +open Syntax +open TyperUtil + +let effect_refresher = + object + inherit [_] s_map as super + + method! visit_ty () ty = + { (super#visit_ty () ty) with teffect = fresh_effect () } + end +;; + +let refresh_prog ds = + List.map + (fun d -> + match d.d with + | DHandler (id, sort, body) -> + let body' = effect_refresher#visit_body () body in + { d with d = DHandler (id, sort, body') } + | DFun (id, rty, cs, body) -> + let body' = effect_refresher#visit_body () body in + { d with d = DFun (id, rty, cs, body') } + | _ -> d) + ds +;; \ No newline at end of file From c9e7dad54dd7a36d6d7d4f3853079143341d733d Mon Sep 17 00:00:00 2001 From: John Sonchack Date: Wed, 20 May 2026 19:45:36 -0400 Subject: [PATCH 2/2] tuple type parens syntax --- src/lib/frontend/Parser.mly | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/lib/frontend/Parser.mly b/src/lib/frontend/Parser.mly index 3943a41e..9b36f712 100644 --- a/src/lib/frontend/Parser.mly +++ b/src/lib/frontend/Parser.mly @@ -263,9 +263,18 @@ poly: single_poly: | LESS size MORE { Span.extend $1 $3, snd $2 } -ty_or_empty_tuple: +ty_or_empty_tuple: | ty { $1 } | LPAREN RPAREN { ty_sp (TTuple([])) (Span.extend $1 $2) } + /* Parenthesized comma-form tuple type, e.g. `(int<48>, int<32>)`. Only + legal inside `<<...>>` slots (Table.t key/data/arg/ret) because that's + the only place `ty_or_empty_tuple` is used. Requires at least two + element types so `(t)` continues to mean a parenthesized single ty, + not a 1-tuple. Avoids the lexer-greedy `>>` issue that `tuple<<...>>` + runs into when the inner type ends in `>`. */ + | LPAREN ty COMMA tys RPAREN { + let raw_tys = List.map (fun ty -> ty.raw_ty) ($2 :: (snd $4)) in + ty_sp (TTuple raw_tys) (Span.extend $1 $5) } ty_polys: | ty_or_empty_tuple { [$1] }