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

Well-formedness checking of declarations #11

Closed
nikomatsakis opened this issue Jan 16, 2017 · 2 comments · Fixed by #82
Closed

Well-formedness checking of declarations #11

nikomatsakis opened this issue Jan 16, 2017 · 2 comments · Fixed by #82

Comments

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Jan 16, 2017

We don't currently do any WF checking. Specifically, it'd be nice to lower each struct/trait/impl into a predicate that, if provable, defines whether the declaration is well-formed. In most cases this is relatively straightforward, though depending how far we go we might need to extend the IR.

For example, structs don't currently list their fields, but the WF rules for structs require that the type of each field is WF. So if we had a struct:

struct Foo<T> {
    b: Bar<T>
}

struct Bar<T> where T: Eq { t: T }

Then the WF predicate for Foo might look like:

StructFooWF :-
    forall<T> {
        WF(Bar<T>)
    }.

This relies on us having the rules for when types are well-formed (which...I think we do? if not, should open a bug on that), which would look like:

WF(Bar<T>) :- T: Eq.

In this case, that would be unprovable, and hence the struct Foo is not considered well-formed (not without a T: Eq where-clause, at least). If we added the T: Eq where clause:

struct Foo<T> where T: Eq { b: Bar<T> }

then we would have:

StructFooWF :-
    forall<T> {
        if (T: Eq) {
            WF(Bar<T>)
        }
    }.

and everything is provable again.

@nikomatsakis nikomatsakis added good first issue A good issue to start working on Chalk with good second bug and removed good first issue A good issue to start working on Chalk with labels Mar 11, 2017
@nikomatsakis nikomatsakis changed the title Well-formedness checking and implied bounds Well-formedness checking of declarations Mar 11, 2017
@nikomatsakis
Copy link
Contributor Author

Probably the first step to tackling this bug is breaking it into steps and opening issues on those =)

withoutboats added a commit to withoutboats/chalk that referenced this issue Mar 14, 2017
Preparation for resolving rust-lang#11.
withoutboats added a commit to withoutboats/chalk that referenced this issue Mar 14, 2017
Preparation for resolving rust-lang#11.
@mrhota
Copy link

mrhota commented Apr 25, 2017

@nikomatsakis can you provide some guidance on what those steps might be?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants