Skip to content

Commit

Permalink
fix: type_of for pointer types (#5536)
Browse files Browse the repository at this point in the history
# Description

## Problem\*

Resolves <!-- Link to GitHub Issue -->

## Summary\*

With the mutability change in the interpreter we now use `Type::Pointer`
for non-`&mut` types. If `auto_deref` is type it signals the variable is
mutable, but not an actual mutable reference type.

## Additional Context



## Documentation\*

Check one:
- [x] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** 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 authored Jul 18, 2024
1 parent c679f01 commit edb3810
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions compiler/noirc_frontend/src/hir/comptime/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ impl Value {
Value::Slice(_, typ) => return Cow::Borrowed(typ),
Value::Code(_) => Type::Quoted(QuotedType::Quoted),
Value::StructDefinition(_) => Type::Quoted(QuotedType::StructDefinition),
Value::Pointer(element, _) => {
let element = element.borrow().get_type().into_owned();
Type::MutableReference(Box::new(element))
Value::Pointer(element, auto_deref) => {
if *auto_deref {
element.borrow().get_type().into_owned()
} else {
let element = element.borrow().get_type().into_owned();
Type::MutableReference(Box::new(element))
}
}
Value::TraitConstraint { .. } => Type::Quoted(QuotedType::TraitConstraint),
Value::TraitDefinition(_) => Type::Quoted(QuotedType::TraitDefinition),
Expand Down

0 comments on commit edb3810

Please sign in to comment.