Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions compiler/noirc_frontend/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ pub mod resolution;
pub mod scope;
pub mod type_check;

use crate::ast::UnresolvedGenerics;
use crate::ast::{IdentOrQuotedType, UnresolvedGenerics};
use crate::debug::DebugInstrumenter;
use crate::elaborator::UnstableFeature;
use crate::graph::{CrateGraph, CrateId};
use crate::hir::def_collector::dc_crate::UnresolvedGlobal;
use crate::hir::def_map::DefMaps;
use crate::hir::resolution::errors::ResolverError;
use crate::hir_def::function::FuncMeta;
use crate::node_interner::{FuncId, GlobalId, NodeInterner, TypeId};
use crate::parser::ParserError;
use crate::usage_tracker::UsageTracker;
use crate::{Kind, ParsedModule, ResolvedGeneric, ResolvedGenerics, TypeVariable};
use crate::{Kind, ParsedModule, ResolvedGeneric, ResolvedGenerics, Type, TypeVariable};
use def_collector::dc_crate::CompilationError;
use def_map::{CrateDefMap, FuzzingHarness, fully_qualified_module_path};
use fm::{FileId, FileManager};
Expand Down Expand Up @@ -288,6 +289,16 @@ impl Context<'_, '_> {
let ident = generic.ident();
let location = ident.location();

if let IdentOrQuotedType::Quoted(quoted_type_id, _) = ident {
let typ = interner.get_quoted_type(*quoted_type_id).follow_bindings();
if !matches!(typ, Type::NamedGeneric(..)) {
errors.push(
ResolverError::MacroResultInGenericsListNotAGeneric { location, typ }
.into(),
);
}
}

// Check for name collisions of this generic
let name = Rc::new(ident.to_string());

Expand Down
7 changes: 7 additions & 0 deletions test_programs/compile_failure/regression_10445/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "regression_10445"
type = "bin"
authors = [""]
compiler_version = ">=0.33.0"

[dependencies]
13 changes: 13 additions & 0 deletions test_programs/compile_failure/regression_10445/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#[foo]
comptime fn foo(_: FunctionDefinition) -> Quoted {
let t = quote { [i32; 3] }.as_type();
quote {
struct Foo<$t> {
x: $t,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if this was instead:

quote {
        struct Bar<T>(T);

        struct Foo {
            x: Bar<$t>,

Does that not go into resolve_generics?

}
}
}

fn main() {
let _ = Foo::<i32> { x: [1, 2, 3] };
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading