Skip to content

[BUG] Concept is generated in type definition section while needed in type declaration section #1388

Open
@MetaZ9

Description

@MetaZ9

Describe the bug
Pretty self-explanatory. Concepts are generated in the type definition section of a generated file (header or source file); but a template class with said concept will be declared in the type declaration section, before the concept is defined, resulting in an error later.

To Reproduce

import <type_traits>;

Foo: @interface type = {}

FooType: <T> concept = std::is_base_of_v<Foo, T>;

Bar: <T: FooType> type = {}

Generated code :

class Foo;

template<FooType T> class Bar; //FooType needed here

import <type_traits>;

class Foo {/* ... */};

template<typename T> concept FooType = std::is_base_of_v<Foo,T>; //FooType only declared here

template<FooType T> class Bar {/* ... */};

Discussion
Since concepts can be used as part of a class declaration, I think they should be placed in the declaration section, even if it's essentially a definition.
That said, I'm not sure it's trivial and I don't know all the implications. I'm not fully familiar with concepts, but it seems to me that you can do quite complex things in concept definitions, perhaps some need more than a simple type declaration to be compiled.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions