From 82da1e14a8570dc441e7f16c62be1c2f55e19ced Mon Sep 17 00:00:00 2001 From: Kai Schmidt Date: Thu, 9 Jan 2025 14:56:43 -0800 Subject: [PATCH] make subscripted on work with function packs --- src/compile/modifier.rs | 13 ++++++++++--- tests/units.ua | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compile/modifier.rs b/src/compile/modifier.rs index 006ba9cfb..dfee4e355 100644 --- a/src/compile/modifier.rs +++ b/src/compile/modifier.rs @@ -114,11 +114,18 @@ impl Compiler { Modifier::Primitive(Primitive::On) => { let mut words = Vec::new(); for branch in pack.branches.iter().cloned() { - words.push(branch.span.clone().sp(Word::Modified(Box::new(Modified { + let mut word = Word::Modified(Box::new(Modified { modifier: modifier.clone(), - operands: vec![branch.map(Word::Func)], + operands: vec![branch.clone().map(Word::Func)], pack_expansion: true, - })))); + })); + if let Some(sub) = &subscript { + word = Word::Subscripted(Box::new(Subscripted { + n: sub.clone(), + word: branch.span.clone().sp(word), + })) + } + words.push(branch.span.sp(word)); } self.words(words) } diff --git a/tests/units.ua b/tests/units.ua index ac393fe9f..8fc8362c7 100644 --- a/tests/units.ua +++ b/tests/units.ua @@ -419,6 +419,8 @@ B ← |1 (⨬(+⊃(B-1|B-2)|1)<2.) ⍤⤙≍ [1 2 3 4] [⟜₂+ 1 2 4] ⍤⤙≍ [1 2 7] [⟜₂(++) 1 2 4] +⍤⤙≍ {1 2 {1 2 [1 2 3]}} {⟜₂({⊙⊙∘}|[⊙⊙∘]) 1 2 3} + # By ⍤⤙≍ [0 5] [⊸0] 5 ⍤⤙≍ [8 5] [⊸+] 3 5