You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ The Makefile’s targets build on each other in this order:
42
42
-**Test early and often** - Add tests immediately after modifying each compiler layer to catch problems early, rather than waiting until all changes are complete
43
43
44
44
-**Use underscore patterns carefully** - Don't use `_` patterns as lazy placeholders for new language features that then get forgotten. Only use them when you're certain the value should be ignored for that specific case. Ensure all new language features are handled correctly and completely across all compiler layers
45
+
-**Avoid `let _ = …` for side effects** - If you need to call a function only for its side effects, use `ignore expr` (or bind the result and thread state explicitly). Do not write `let _ = expr in ()`, and do not discard stateful results—plumb them through instead.
45
46
46
47
-**Be careful with similar constructor names across different IRs** - Note that `Lam` (Lambda IR) and `Lambda` (typed lambda) have variants with similar constructor names like `Ltrywith`, but they represent different things in different compilation phases.
Each bullet above should be done as a separate patch touching only a small set of functions.
197
197
198
-
### 4.3 Localise `Current.*` binding state
198
+
### 4.3 Localise `Current.*` binding/reporting state
199
199
200
-
Goal: remove `DeadCommon.Current.bindings`, `lastBinding`, and `maxValuePosEnd` as mutable globals by turning them into local state threaded through functions.
200
+
Goal: remove `DeadCommon.Current` globals for binding/reporting by threading explicit state.
201
201
202
-
-[ ] In `DeadCommon`, define:
203
-
```ocaml
204
-
type current_state = {
205
-
bindings : PosSet.t;
206
-
last_binding : Location.t;
207
-
max_value_pos_end : Lexing.position;
208
-
}
209
-
210
-
let empty_current_state = {
211
-
bindings = PosSet.empty;
212
-
last_binding = Location.none;
213
-
max_value_pos_end = Lexing.dummy_pos;
214
-
}
215
-
```
216
-
-[ ] Change `addValueReference` to take a `current_state` and return an updated `current_state` instead of reading/writing `Current.*`. For the first patch, implement it by calling the existing global‑based logic and then mirroring the resulting values into a `current_state`, so behaviour is identical.
217
-
-[ ] Update the places that call `addValueReference` (mainly in `DeadValue`) to thread a `current_state` value through, starting from `empty_current_state`, and ignore `Current.*`.
218
-
-[ ] In a follow‑up patch, re‑implement `addValueReference` and any other helpers that touch `Current.*` purely in terms of `current_state` and delete the `Current.*` refs from DCE code.
219
-
220
-
At the end of this step, binding‑related state is explicit and confined to the call chains that need it.
202
+
-[x] Add `Current.state`/helpers in `DeadCommon` and thread it through `DeadValue` (bindings) and `DeadException.markAsUsed` so `last_binding` is no longer a global ref.
203
+
-[x] Replace `Current.maxValuePosEnd` with a per‑reporting `Current.state` in `Decl.report`/`reportDead`.
204
+
-[ ] Follow‑up: remove `Current.state ref` usage by making traversals return an updated state (pure, no mutation). Adjust `addValueReference_state` (or its successor) to be purely functional and always return the new state.
221
205
222
206
### 4.4 Make `ProcessDeadAnnotations` state explicit
223
207
@@ -398,4 +382,3 @@ Recommended rough order of tasks (each remains independent and small):
398
382
8. 4.14 – Add and maintain order‑independence tests.
399
383
400
384
Each checkbox above should be updated to `[x]` as the corresponding change lands, keeping the codebase runnable and behaviour‑preserving after every step.
0 commit comments