[BUG] comptime AllCopyable overload specialization causes redefinition error for Copyable-constrained packs
Nobody has claimed this yet.
- Dominant language
- Mojo
- Stars
- 29.8k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
Bug description
Problem
When Variant[*Ts] is built from a TypeList.map[...]() result,
the compiler fails to prove AllCopyable[*Ts], so Variant loses
Copyable conformance even though every element is Copyable.
oss/modular/mojo/stdlib/std/reflection/traits.mojo:41:1: error: invalid redefinition of 'AllCopyable'
comptime AllCopyable[*Ts: AnyType]: Bool = Ts.all_satisfies[
^
Included from "oss/modular/mojo/stdlib/std/reflection/__init__.mojo":1:
oss/modular/mojo/stdlib/std/reflection/traits.mojo:39:1: note: previous definition here
comptime AllCopyable[*Ts: Copyable]: Bool = True
^
Attempted Fix
Added a specialized comptime overload in traits.mojo:
comptime AllCopyable[*Ts: Copyable]: Bool = True
However this causes a redefinition error — suggesting comptime
does not support overload specialization.
Conclusion
This appears to need a compiler-level fix rather than
a stdlib workaround.
References
- Original issue: #6498
- Attempted PR: #6504
System information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with oss/modular/mojo/stdlib/std/reflection/traits.mojo, especially the two AllCopyable definitions and the compiler error locations. Review the context from issues #6498 and #6504, then reproduce the Variant[*Ts] case using a TypeList.map... result. Done means the compiler no longer reports a redefinition and Variant retains Copyable conformance when all elements are Copyable.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100