Skip to content

Commit

Permalink
fix a bug with proxy values in rows
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jun 19, 2024
1 parent c006c57 commit 03d6b40
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/algorithm/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ fn rows2(f: Function, mut xs: Value, mut ys: Value, env: &mut Uiua) -> UiuaResul
let per_meta = xs.take_per_meta();
env.without_fill(|env| -> UiuaResult {
if is_empty {
env.push(ys.proxy_row(env));
env.push(ys);
env.push(xs.proxy_row(env));
_ = env.call_maintain_sig(f);
for i in 0..outputs {
Expand Down Expand Up @@ -642,7 +642,7 @@ fn rows2(f: Function, mut xs: Value, mut ys: Value, env: &mut Uiua) -> UiuaResul
env.without_fill(|env| -> UiuaResult {
if is_empty {
env.push(ys.proxy_row(env));
env.push(xs.proxy_row(env));
env.push(xs);
_ = env.call_maintain_sig(f);
for i in 0..outputs {
new_rows[i].push(env.pop("rows's function result")?);
Expand Down Expand Up @@ -696,8 +696,16 @@ fn rows2(f: Function, mut xs: Value, mut ys: Value, env: &mut Uiua) -> UiuaResul
let per_meta = xs.take_per_meta().xor(ys.take_per_meta());
env.without_fill(|env| -> UiuaResult {
if is_empty {
env.push(ys.proxy_row(env));
env.push(xs.proxy_row(env));
env.push(if ys.row_count() == 0 {
ys.proxy_row(env)
} else {
ys
});
env.push(if xs.row_count() == 0 {
xs.proxy_row(env)
} else {
xs
});
_ = env.call_maintain_sig(f);
for i in 0..outputs {
new_rows[i].push(env.pop("rows's function result")?);
Expand Down Expand Up @@ -1182,7 +1190,7 @@ fn inventoryn(f: Function, mut args: Vec<Value>, env: &mut Uiua) -> UiuaResult {
v.unbox();
Err(v)
} else {
let proxy = is_empty.then(|| v.proxy_row(env));
let proxy = (is_empty || v.row_count() == 0).then(|| v.proxy_row(env));
row_count = row_count.max(v.row_count());
all_1 = false;
Ok(v.into_rows().map(Value::unboxed).chain(proxy))
Expand Down
1 change: 1 addition & 0 deletions tests/units.ua
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ F ← +@A ⊟.
⍤⟜≍: ⊂:2_2 ⟜(⊂⊃△type≡F⇡)2
⍤⟜≍: ⊂:2_2 ⟜(⊂⊃△type≡F⇡)1
⍤⟜≍: ⊂:2_2 ⟜(⊂⊃△type≡F⇡)0
assonmat: [0 3] shape ≡⍜▽∘ ↯0_3 1 ¤"abc"

# Filled inverses
⍤⟜≍: 0 ⬚0°◌
Expand Down

0 comments on commit 03d6b40

Please sign in to comment.