Skip to content

Commit

Permalink
Merge branch 'master' into arv/consistent_binary_ops
Browse files Browse the repository at this point in the history
  • Loading branch information
sirasistant authored Mar 13, 2024
2 parents 13fbea3 + 00d6494 commit 29606ea
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 5 additions & 5 deletions compiler/noirc_frontend/src/hir/def_collector/dc_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,6 @@ impl DefCollector {
// Must resolve structs before we resolve globals.
errors.extend(resolve_structs(context, def_collector.collected_types, crate_id));

// We must wait to resolve non-integer globals until after we resolve structs since struct
// globals will need to reference the struct type they're initialized to to ensure they are valid.
resolved_globals.extend(resolve_globals(context, other_globals, crate_id));
errors.extend(resolved_globals.errors);

// Bind trait impls to their trait. Collect trait functions, that have a
// default implementation, which hasn't been overridden.
errors.extend(collect_trait_impls(
Expand All @@ -349,6 +344,11 @@ impl DefCollector {
// over trait methods if there are name conflicts.
errors.extend(collect_impls(context, crate_id, &def_collector.collected_impls));

// We must wait to resolve non-integer globals until after we resolve structs since struct
// globals will need to reference the struct type they're initialized to to ensure they are valid.
resolved_globals.extend(resolve_globals(context, other_globals, crate_id));
errors.extend(resolved_globals.errors);

// Resolve each function in the crate. This is now possible since imports have been resolved
let mut functions = Vec::new();
functions.extend(resolve_free_functions(
Expand Down
17 changes: 17 additions & 0 deletions test_programs/execution_success/global_consts/src/main.nr
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,20 @@ mod my_submodule {
x
}
}

struct Foo {
a: Field,
}

struct Bar {}

impl Bar {
fn get_a() -> Field {
1
}
}

// Regression for #1440
global foo = Foo {
a: Bar::get_a(),
};

0 comments on commit 29606ea

Please sign in to comment.