Open bradcray opened 2 years ago
The problem is that Node
is a generic type (it has generic memory management). This is tangentially related to #19120 (in that if you had to write Node(?)
in the class for the left
field maybe you would be aware of it in the rest of the program).
Since the compiler knows Node
is a generic type,
proc lineToTree(line: string, ref pos: int): Node {
var left, right: Node; // type is generic, so relying on split-init
left = lineToTree(line, pos); // recursive function call
// -> can't infer return type, so use declared return type.
// But declared return type is generic.
I think you're saying "the problem was yours, and it's appropriate that the compiler is generating an error for this program", but it's not clear to me whether you're also saying "and the error message we have doesn't need improving."
Specifically, I was confused about the note about default initialization pointing to the line where I was explicitly either initializing or assigning it rather than the line where the declaration occurred (which is where I think of the default initialization happening—am I wrong about that?). And of course the reference to <temporary>
didn't help since I couldn't figure out what that was referring to.
For sure the error message could be better. Besides improving the line numbers, it could mention that it's generic due to the class having generic management.
Summary of Problem
On a line of Chapel in which I did not believe I was default initializing anything, the compiler gave me an error message about default initializing a variable with generic type. I'm not certain whether the problem is mine or the compiler's, but if mine, I think the error message needs to be clarified for the end-user.
Capturing the error message here in case others hit cases like this:
Steps to Reproduce
Associated Future Test(s):
test/studies/adventOfCode/2021/bradc/futures/day18-bug.chpl
#19028Configuration Information
chpl --version
:chpl version 1.26.0 pre-release (56bd177336)