CoPilot is helpless if it needs to do more than just regurgitate someone else's code.
The training of these models on GitHub, so they regurgitate licensed code without attribution, is the greatest theft of intellectual property in the history of Man. Perhaps not according to the letter of the law, but surely according to the spirit.
I like CoPilot's answer better than yours, and I think it's closer to what most people would do; clearly 0x3F is the wrong constant but the approach is good.
For fun I rephrased the prompt a little. "Middle bits" is kind of vague; when provided an explicit description of which bits you want to set it does fine:
Prompt:
// Function to set bits 29-34 in a uint64 to 1
func setbits (uint64 x) uint64 {
Middle bits is not ambiguous, but CoPilot hasn't seen code for that phrase in its training so it has nothing to regurgitate.
You spelled out exactly what to do, in term of what it has seen in its training, and it was able to regurgitate a solution.
By asking question that require mathematical reasoning or are too far from the training corpus, I can create an endless list of simple problems that CoPilot can't solve.
Look at my comment history to see another one (swapping bits).
CoPilot is helpless if it needs to do more than just regurgitate someone else's code.
The training of these models on GitHub, so they regurgitate licensed code without attribution, is the greatest theft of intellectual property in the history of Man. Perhaps not according to the letter of the law, but surely according to the spirit.