Skip to content

Commit

Permalink
fix a bug in array macro compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Jun 17, 2024
1 parent 88f0f4c commit 5495309
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/compile/modifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,13 +1182,25 @@ impl Compiler {
}

// Compile the generated items
for item in items {
let item_count = items.len();
for (i, item) in items.into_iter().enumerate() {
match item {
Item::Words(words) => {
let call = call || i != item_count - 1;
if !call {
self.new_functions.push(EcoVec::new());
}
for line in words {
self.words(line, call)
self.words(line, true)
.map_err(|e| e.trace_macro(span.clone()))?;
}
if !call {
let instrs = self.new_functions.pop().unwrap();
let sig = self.sig_of(&instrs, span)?;
let id = FunctionId::Anonymous(span.clone());
let func = self.make_function(id, sig, instrs);
self.push_instr(Instr::PushFunc(func));
}
}
Item::Binding(binding) => self
.binding(binding, None)
Expand Down
3 changes: 3 additions & 0 deletions tests/macros.ua
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ E! ←^ $"_" e ◌
◌C!3
◌D!4
◌E!5

F! ←^ {"+" "1"}◌
⍤⟜≍: [2 3 4] ≡F!∘ [1 2 3]

0 comments on commit 5495309

Please sign in to comment.