diff --git a/core/compiler/src/solver.rs b/core/compiler/src/solver.rs index d68e58c..5b16cbf 100644 --- a/core/compiler/src/solver.rs +++ b/core/compiler/src/solver.rs @@ -94,10 +94,7 @@ impl Solver { let id = self.next_constraint; self.next_constraint += 1; for (_, var) in &expr.coeffs { - self.var_to_constraints - .entry(*var) - .or_insert(IndexSet::new()) - .insert(id); + self.var_to_constraints.entry(*var).or_default().insert(id); } self.constraints.insert(id, expr); // Use explicit stack in heap-allocated vector to avoid stack overflow. diff --git a/core/compiler/src/std/lib.ar b/core/compiler/src/std/lib.ar index b3b41e6..c4788a8 100644 --- a/core/compiler/src/std/lib.ar +++ b/core/compiler/src/std/lib.ar @@ -87,7 +87,15 @@ fn array2(r: Rect, nx: Int, ny: Int, xpitch: Float, ypitch: Float) -> Rect { fn max_array(r: Rect, w: Float, h: Float, xpitch: Float, ypitch: Float) -> Rect { let nx = (((w - r.w) / xpitch) as Int + 1); let ny = (((h - r.h) / ypitch) as Int + 1); - #scope0 array2(r, nx, ny, xpitch, ypitch) + if nx >= 1 { + if ny >= 1 { + #scope0 array2(r, nx, ny, xpitch, ypitch) + } else { + crect(w=0., h=0.) + } + } else { + crect(w=0., h=0.) + } } fn eq_rect(r1: Rect, r2: Rect) {