Skip to content

representable check fails if an enum references another enum that is cyclic #3008

Closed
@nikomatsakis

Description

@nikomatsakis

Here is a test case:

// Compiler fails here because it starts to check foo which references
// bar which is cyclic.
enum foo { foo(bar) }
enum bar { bar_none, bar_some(bar) }

// As before, but with order reversed, so that should we happen to
// start checking from end of file forward, we'd still have the same
// problem.
enum bar1 { bar1_none, bar1_some(bar1) }
enum foo1 { foo1(bar1) }

fn main() {}

I think the right approach is to replace ty_structurally_contains() with something like walk_interior_tys(). then we have to keeep a stack of def-ids and when we enter a new nominal type check that we do not already have it on the stack. i started this then realized it was a big distraction from what I'm trying to do, so filing a bug instead. Marking as A-typesystem as this check is performed in middle/typeck/check.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.P-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions