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

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

Closed
nikomatsakis opened this issue Jul 24, 2012 · 8 comments · Fixed by #11839
Closed

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

nikomatsakis opened this issue Jul 24, 2012 · 8 comments · Fixed by #11839
Labels
A-type-system Area: Type system E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority
Milestone

Comments

@nikomatsakis
Copy link
Contributor

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

@pnkfelix
Copy link
Member

Just to make this concrete: both of the cases that Niko describes yield ICE's. The first (the foo and bar items) yields an ICE with no useful error information. The second (bar1 and foo1) yields an error describing the illegal recursive enum type (followed by an ICE :).

@pcwalton
Copy link
Contributor

I don't believe this is backwards incompatible, renominating.

@graydon
Copy link
Contributor

graydon commented Jun 6, 2013

accepted for production-ready milestone

@bblum
Copy link
Contributor

bblum commented Aug 16, 2013

appears to be properly classified

@pnkfelix
Copy link
Member

Accepting for P-high.

@pnkfelix
Copy link
Member

Tagging as mentorship bug, with @nikomatsakis as mentor

@isabelmu
Copy link
Contributor

This code triggers the same infinite recursion in type_structurally_contains:

enum E { A, B(Bad) }
struct Bad { x: Bad }

@isabelmu
Copy link
Contributor

I have a fix for this written, in case anyone is wondering whether to start working on it. I'll submit a pull request soon.

@bors bors closed this as completed in 056363f Jan 30, 2014
@c410-f3r c410-f3r mentioned this issue May 29, 2023
RalfJung pushed a commit to RalfJung/rust that referenced this issue Sep 28, 2023
bump ui test crate

The recommended way to run tests locally is `./miri bless -- -- --quiet`, which will show

* progress bars
* the currently running tests (allowing you to see which ones are still running towards the end of the test suite)
* the output of the currently running tests (if they are slow). This means slow running tests can output lines to `stderr` and the last line will be shown after the test name and updated every few hundred milliseconds.

As a side effect this PR also fixes rust-lang#2998 and only builds dependencies if any tests actually need them (this means that with the next ui_test update we'll be able to merge all our test suites).

Also fixes rust-lang/miri#3052.
celinval pushed a commit to celinval/rust-dev that referenced this issue Jun 4, 2024
Resolves model-checking/kani#3007.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Signed-off-by: Felipe R. Monteiro <felisous@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-mentor Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion. P-medium Medium priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants