Skip to content

Commit

Permalink
Generative variables in types also count as 'used'
Browse files Browse the repository at this point in the history
  • Loading branch information
VonTum committed Jan 4, 2024
1 parent 7426462 commit 6de82e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion multiply_add.sus
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ module generative : int in -> int o, int o2 {

gen int[3] ps;

gen int[3] a;
gen int[x] a;

a[2] = 5;
a[1] = 2;
Expand Down
4 changes: 3 additions & 1 deletion src/flattening.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,9 @@ impl FlattenedModule {
}
};
match &self.instantiations[item] {
Instantiation::WireDeclaration(_) => {}
Instantiation::WireDeclaration(decl) => {
decl.typ.for_each_generative_input(&mut func);
}
Instantiation::Wire(wire) => {
wire.source.for_each_input_wire(&mut func);
}
Expand Down
10 changes: 10 additions & 0 deletions src/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ impl Type {
Type::Array(sub) => sub.0.get_root(),
}
}
pub fn for_each_generative_input<F : FnMut(FlatID)>(&self, f : &mut F) {
match self {
Type::Error => {}
Type::Unknown => {}
Type::Named(_) => {}
Type::Array(arr_box) => {
f(arr_box.deref().1)
}
}
}
}

pub fn typecheck_unary_operator(op : Operator, input_typ : &Type, span : Span, linker : &Linker, errors : &ErrorCollector) -> Type {
Expand Down

0 comments on commit 6de82e7

Please sign in to comment.