Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler checking if the current function is constrained #4318

Closed
sirasistant opened this issue Feb 9, 2024 · 0 comments · Fixed by #4320
Closed

Compiler checking if the current function is constrained #4318

sirasistant opened this issue Feb 9, 2024 · 0 comments · Fixed by #4320
Assignees
Labels
bug Something isn't working

Comments

@sirasistant
Copy link
Contributor

Aim

Compiling in aztec packages with current noir master.

Expected Behavior

Should compile!

Bug

Panics with

The application panicked (crashed).
Message:  Can only have call expression inside of a function body
Location: compiler/noirc_frontend/src/hir/type_check/expr.rs:158

Patterns like this one might be the culprit:

global HEADER = Header {
    last_archive: empty_append_only_tree(),
    body_hash: [0; NUM_FIELDS_PER_SHA256],
    state: StateReference {
        l1_to_l2_message_tree: empty_append_only_tree(),
        partial: PartialStateReference {
            note_hash_tree: AppendOnlyTreeSnapshot {
                root: fixtures::note_hash_tree::ROOT,
                next_available_leaf_index: 0, // TODO: should this be populated?
            },
            nullifier_tree: empty_append_only_tree(),
            contract_tree: AppendOnlyTreeSnapshot {
                root: fixtures::contract_tree::ROOT,
                next_available_leaf_index: 0, // TODO: should this be populated?
            },
            public_data_tree: empty_append_only_tree()
        }
    },
    global_variables: GlobalVariables {
        chain_id: 0,
        version: 0,
        block_number: 0,
        timestamp: 0,
        coinbase: empty_eth_address(),
        fee_recipient: empty_aztec_address(),
    }
};

To Reproduce

Project Impact

None

Impact Context

No response

Workaround

Yes

Workaround Description

    let is_current_func_constrained = self
                    .current_function
                    .map(|func| {
                        let func_mod = self.interner.function_modifiers(&func);
                        !func_mod.is_unconstrained
                    })
                    .unwrap_or(true); // If there is no current function, then we assume it is constrained

Additional Context

No response

Installation Method

None

Nargo Version

No response

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@sirasistant sirasistant added the bug Something isn't working label Feb 9, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Feb 9, 2024
@TomAFrench TomAFrench assigned TomAFrench and unassigned vezenovm Feb 9, 2024
github-merge-queue bot pushed a commit that referenced this issue Feb 9, 2024
# Description

## Problem\*

Resolves #4318 

## Summary\*

I've added the necessary `Option` handling for us to make calls from the
global context.

## 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.

---------

Co-authored-by: jfecher <[email protected]>
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants