Skip to content

Commit

Permalink
Type inference ignores generic arguments (#1551)
Browse files Browse the repository at this point in the history
This PR solves issue #1550
  • Loading branch information
gzanitti committed Jul 9, 2024
1 parent 4752a36 commit 50c35fa
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion importer/src/path_canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ fn canonicalize_inside_expression(
Expression::Reference(_, reference) => {
// If resolving the reference fails, we assume it is a local variable that has been checked below.
if let Some(n) = paths.get(&path.clone().join(reference.path.clone())) {
*reference = n.relative_to(&Default::default()).into();
reference.path = n.relative_to(&Default::default());
} else {
assert!(reference.path.try_to_identifier().is_some());
}
Expand Down
6 changes: 6 additions & 0 deletions pipeline/tests/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,3 +731,9 @@ fn connect_no_witgen() {
let i = [];
verify_asm(f, slice_to_vec(&i));
}

#[test]
fn generics_preservation() {
let f = "asm/generics_preservation.asm";
verify_asm(f, Default::default());
}
20 changes: 20 additions & 0 deletions test_data/asm/generics_preservation.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
mod cols {
enum Generic<T> {
A(T),
B,
}
let<T> f: -> Generic<T> = || {
Generic::B
};
}


machine Empty {
let x;
let fi: col = |i| match cols::f::<int>() {
cols::Generic::A(_) => 7,
cols::Generic::B => 9,
};
x = fi;

}

0 comments on commit 50c35fa

Please sign in to comment.