ITADN

`where Wrapper(.Self) impls Core.Copy` constraint not used by impl lookup inside function body

#7028Closedizagawd 创建于 2026-04-06
toolchain
I
izagawdcommented
### Description of the bug: When a generic function constrains a type parameter with where Wrapper(.Self) impls Core.Copy, the compiler accepts the constraint at call sites but does not use it to enable copy operations on Wrapper(T) inside the function body. https://godbolt.org//x3xWahhzq ### What did you do, or what's a simple way to reproduce the bug? Here is a simple way to reproduce the bug ```carbon class Wrapper(T:! type){} impl forall[T:! Core.Copy] Wrapper(T) as Core.Copy{ fn Op[self: Self]() -> Self{ return {}; } } fn Yo(T:! type where Wrapper(.Self) impls Core.Copy, wrapper: Wrapper(T)){ var copied : Wrapper(T) = wrapper; var copiedAgain : Wrapper(T) = wrapper; } fn Run(){} ``` ### What did you expect to happen? The function body should be able to copy wrapper since the constraint guarantees thatr Wrapper(T) impls Core.Copy. ### What actually happened? It gave this error: ``` <source>:12:31: error: cannot copy value of type `Wrapper(T)` var copied : Wrapper(T) = wrapper; ^~~~~~~ ``` And didn't compile ### Any other information, logs, or outputs that you want to share? I suspect that this issue may not just only occur in function bodies. It might also occur in interface implementation where bounds.
关闭于 2026-04-07 1 条评论