Refactor analyzer to return impurity

The `Analyzer` is now responsible for determining the purity of `Define`
bindings. Previously, this responsibility was left to the caller.

Added a new example `design-flaw.myc` to test this change.
Updated `soa_series.myc` due to the purity change.
This commit is contained in:
Michael Schimmel
2026-03-10 16:13:39 +01:00
parent 348b1686f2
commit 961168f3b6
4 changed files with 11 additions and 4 deletions
+7
View File
@@ -0,0 +1,7 @@
(do
(do
(def x "hh")
)
(print x)
)
+1 -1
View File
@@ -1,4 +1,4 @@
;; Output: 228
;; Output: 26.7
;; Benchmark: 1.4us
;; Benchmark-Repeat: 1406
(do
+1 -2
View File
@@ -116,7 +116,6 @@ impl<'a> Analyzer<'a> {
captured_by,
} => {
let val_m = self.visit(value.clone());
let p = val_m.ty.purity;
(
BoundKind::Define {
name: name.clone(),
@@ -125,7 +124,7 @@ impl<'a> Analyzer<'a> {
value: Rc::new(val_m),
captured_by: captured_by.clone(),
},
p,
Purity::Impure,
)
}
+2 -1
View File
@@ -143,7 +143,8 @@ impl UsageInfo {
self.collect(v);
}
}
BoundKind::Define { value, .. } => {
BoundKind::Define { addr, value, .. } => {
self.assigned.insert(*addr);
self.collect(value);
}
BoundKind::Expansion { bound_expanded, .. } => {