Comments (6)
It seems related to the fact that U
is unused when proving <T as Foo>::Item<U>: Bar
. For example, the following goal answers Unique
as expected:
trait Bar<T> { }
trait Foo { type Item<T>: Bar<T>; }
forall<T, U> {
if (T: Foo) {
<T as Foo>::Item<U>: Bar<U>
}
}
Also, considering these lines:
https://github.com/rust-lang-nursery/chalk/blob/d67e5691557b09cfd725d18895c436b3c5f12dbf/src/ir.rs#L369-L380
if I change the Ty::Projection
to the skolemized type, I also get No solution
for the goal cited above:
forall<T, U, V> {
if (T: Foo<Item<U> = V>) {
V: Bar
}
}
so it seems to be linked with the skolemized type.
from chalk.
Ok the funny thing is that this goal:
forall<U, T> {
if (T: Foo) {
<T as Foo>::Item<U>: Bar
}
}
(note that T
and U
are reversed) answers Unique
=)
Basically, in the setting described in my first comment, we are looking for a type ?0
which satisfies:
ProjectionEq(<!1 as Foo>::Item<!2> = (Foo::Item)<?0, !1>)
so ?0
gets to unify with !2
but the problem is that ?0
is in universe U1
so it fails... Hence if the variables are reversed, this works. I don't really know what to think about this.
from chalk.
OK, let me try to spell out what is happening. I see the problem that @scalexm specified:
- we start out wanting to solve
!1: Foo => <?0 as Bar>::Item<?1> = ?2, ?2: Bar
- we go seeking a solution to
!1: Foo => ?0: Foo
- this is u-canonicalized to have
?0
inU1
, sinceU2
is not relevant u_canonicalization
puts?0
intoU1
, since that is the maximal universe we can see- we then unify it with
?0
with the skolemized result; this includes a free existential variable, whch winds up inU1
- this is u-canonicalized to have
- when this result is re-instantiated in the, it keeps this universe.
I think this last step is in error. I think when we re-instantiate an answer, we should create its variables in the most recent universe within the caller.
from chalk.
I have a branch (issue-144
) that fixes the test, but I'm not sure it's totally the right fix overall. It instantiates existentials in the context of their caller; this seems fine for the goals, but I'm a bit nervous about it with respect to region constraints. I'll have to see if I can craft a counter example.
from chalk.
@scalexm and I were talking about the bug that I am afraid in #wg-traits on Discord (GUID b713dffa-1603-43c9-8418-3dc11979487c, that marks the end).
UPDATE: link to Discord
from chalk.
This can no longer be reproduced with ef45646:
?- forall<T, U> { if (T: Foo) { <T as Foo>::Item<U>: Bar } }
Unique; substitution [], lifetime constraints []
from chalk.
Related Issues (20)
- CI Publish job using Mac runner HOT 2
- When Rust 1.55 hits stable, replace `ControlFlow` with std version
- Recursive solver reports ambiguity HOT 7
- Idea: rework how SLG solver uses the environment
- Auto traits are not handled for generic closures HOT 8
- Consider removing unused field
- Clean up coherence chapter in the Chalk book HOT 1
- Ambiguity through unrelated env clauses because of implied bounds HOT 1
- reconcile SLG/recursive solver's attempts to merge multiple results
- book: hard to read mermaid diagram in dark themes
- Lowered command panics with auto trait HOT 1
- Recursive solver hangs on cyclic traits HOT 3
- mdbook-mermaid needs updating
- Unable to deduce projection types of dyn types from supertrait bounds
- ICE: negative subgoal had delayed_subgoals HOT 2
- any progress and roadmap? HOT 1
- Automatic releases have been failing for a couple of months
- Branch protection prevents automatic releases from updating the version number on the `master` branch
- Recursive Solver fails to solve recursive associated type with GAT
- Fails to solve some existential clause HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chalk.