Skip to content

Commit

Permalink
[FIX] fixing #42
Browse files Browse the repository at this point in the history
  • Loading branch information
Cr0a3 committed Oct 30, 2024
1 parent 519913a commit d642342
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/IR/func.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl FunctionType {
index += 1;
}

panic!("the func has {} but argument {} wants to get accesed", self.args.len(), num)
panic!("the func has {} args but args {} is accesed", self.args.len(), num)
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ impl Function {

for index in 0..self.ty.args.len() {
let arg = self.ty.arg(index);
fmt += &format!("{} %{}, ", arg.ty, arg.name);
fmt += &format!("{} {}, ", arg.ty, arg.name);
}

if self.ty.args.len() > 0 {
Expand Down Expand Up @@ -189,7 +189,7 @@ impl Function {
let arg = self.ty.arg(index);
fmt += &format!("{} {}, ",
profile.markup(&arg.ty.to_string(), ColorClass::Ty),
profile.markup(&format!("%{}", arg.name), ColorClass::Var)
profile.markup(&format!("{}", arg.name), ColorClass::Var)
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/IR/parser/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl IrGen {
}

fn gen_func(&mut self, name: String, ret: TypeMetadata, args: (BTreeMap<String, TypeMetadata>, bool), body: Vec<(String, IrBlock)>, scope: Linkage) {
let mut ty = FunctionType::new(vec![], ret);
let mut ty = FunctionType::new(Vec::new(), ret);

for (name, arg) in &args.0 {
ty.args.push( (name.to_owned(), *arg) );
Expand Down
2 changes: 1 addition & 1 deletion tests/Optimizations/const_eval/div.yl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define i32 @div(i32 %0) {
}

# STDERR:
define i32 @div(i32 %%0) {
define i32 @div(i32 %0) {
entry:
%1 = i32 1
ret i32 1
Expand Down
16 changes: 16 additions & 0 deletions tests/bugs/arg_printing.yl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# RUN:
cargo run -p ylc -- -in=%s -fmt
# IN:

define i32 @add(i32 %a, i32 %b) {
entry:
%1 = add i32 %a, %b
ret i32 %1
}

# STDERR:
define i32 @add(i32 %a, i32 %b) {
entry:
%1 = add i32 %a, %b
ret i32 %1
}

0 comments on commit d642342

Please sign in to comment.