Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go2go: cannot use x (variable of type X(T)) as X(T) value in assignment #40300
What did you do?
Tried to compile this program (playground link):
What did you expect to see?
No output, as in this program (playground link):
What did you see instead?
I tried to minimize the code as much as possible, that's why the original intent is a bit obscured.
I suspect that this is a bug in the prototype - at least I see no reason why it would work with
I'd be interested to know if this is WAI or a limitation of the prototype.
This appears to be an evaluation/type-checking ordering problem caused by the mutually referencing types. Moving the declaration of type
This (and related issues) require some significant re-engineering of the type-checker. Probably won't address in the prototype, in favor of spending engineering effort on a real implementation. Leaving open so we have a test case.