From edb3810c6863e3c7802fcaece82eb6de21ebd71f Mon Sep 17 00:00:00 2001 From: jfecher Date: Thu, 18 Jul 2024 08:48:52 -0500 Subject: [PATCH] fix: type_of for pointer types (#5536) # Description ## Problem\* Resolves ## 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. --- compiler/noirc_frontend/src/hir/comptime/value.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/noirc_frontend/src/hir/comptime/value.rs b/compiler/noirc_frontend/src/hir/comptime/value.rs index 0cbf4662f6a..a5f35e144cd 100644 --- a/compiler/noirc_frontend/src/hir/comptime/value.rs +++ b/compiler/noirc_frontend/src/hir/comptime/value.rs @@ -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),