Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LHerskind committed Jul 6, 2023
1 parent 42a6cc5 commit 408d491
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions crates/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ impl Driver {

let function_type = ContractFunctionType::new(func_type, func_meta.is_unconstrained);

let is_internal = match func_meta.is_contract_function_internal.is_some() {
true => func_meta.is_contract_function_internal.unwrap(),
let is_internal = match func_meta.is_internal.is_some() {
true => func_meta.is_internal.unwrap(),
false => false,
};

Expand Down
21 changes: 11 additions & 10 deletions crates/noirc_frontend/src/hir/resolution/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl<'a> Resolver<'a> {
kind: func.kind,
attributes,
contract_function_type: self.handle_function_type(func),
is_contract_function_internal: self.handle_is_function_internal(func),
is_internal: self.handle_is_function_internal(func),
is_unconstrained: func.def.is_unconstrained,
location,
typ,
Expand Down Expand Up @@ -706,15 +706,16 @@ impl<'a> Resolver<'a> {
}

fn handle_is_function_internal(&mut self, func: &NoirFunction) -> Option<bool> {
if self.in_contract() {
Some(func.def.is_internal)
} else {
if func.def.is_internal {
self.push_err(ResolverError::ContractFunctionInternalInNormalFunction {
span: func.name_ident().span(),
});
None
}
if self.in_contract() {
Some(func.def.is_internal)
} else {
if func.def.is_internal {
self.push_err(ResolverError::ContractFunctionInternalInNormalFunction {
span: func.name_ident().span(),
});
}
None
}
}

fn declare_numeric_generics(&mut self, params: &[Type], return_type: &Type) {
Expand Down
2 changes: 1 addition & 1 deletion crates/noirc_frontend/src/hir/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ mod test {
attributes: None,
location,
contract_function_type: None,
is_contract_function_internal: None,
is_internal: None,
is_unconstrained: false,
typ: Type::Function(vec![Type::field(None), Type::field(None)], Box::new(Type::Unit)),
parameters: vec![
Expand Down
3 changes: 2 additions & 1 deletion crates/noirc_frontend/src/hir_def/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ pub struct FuncMeta {

/// This function's visibility.
/// If this function is internal can only be called by itself.
pub is_contract_function_internal: Option<bool>,
/// Will be None if not in contract.
pub is_internal: Option<bool>,

pub is_unconstrained: bool,

Expand Down

0 comments on commit 408d491

Please sign in to comment.