Skip to content

Commit

Permalink
fix: Use correct type for numeric generics (#4386)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves #4290 

## Summary\*

Previously, the monomorphizer would assume all numeric generics were
Fields, but this was not necessarily true.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[Exceptional Case]** Documentation to be submitted in a separate
PR.

# PR Checklist\*

- [x] I have tested the changes locally.
- [x] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
  • Loading branch information
jfecher committed Feb 15, 2024
1 parent 4f4f24f commit 0a1d109
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/noirc_frontend/src/monomorphization/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ impl<'interner> Monomorphizer<'interner> {
let mutable = definition.mutable;
let location = Some(ident.location);
let name = definition.name.clone();
let typ = self.interner.id_type(expr_id);
let definition = self.lookup_function(*func_id, expr_id, &typ, None);
let typ = self.convert_type(&typ);
let ident = ast::Ident { location, mutable, definition, name, typ: typ.clone() };
Expand Down Expand Up @@ -755,7 +754,8 @@ impl<'interner> Monomorphizer<'interner> {

let value = FieldElement::from(value as u128);
let location = self.interner.id_location(expr_id);
ast::Expression::Literal(ast::Literal::Integer(value, ast::Type::Field, location))
let typ = self.convert_type(&typ);
ast::Expression::Literal(ast::Literal::Integer(value, typ, location))
}
}
}
Expand Down

0 comments on commit 0a1d109

Please sign in to comment.