19115, "bradcray", "Confusing error messages when initializing 'owned' fields from 'const' actuals", "2022-01-26T01:10:13Z"
Summary of Problem
While trying to initialize an owned C field from an actual argument with default intent and generic type C, the compiler's error message is not particularly clear, talking in terms of passing arguments to init= rather than talking more directly in terms of initialization. Capturing the error here in case users hit it and are confused by it, and as a case that could be improved:
day18-bug3.chpl:11: In initializer:
day18-bug3.chpl:13: error: const actual is passed to a 'ref' formal of init=()
day18-bug3.chpl:14: error: const actual is passed to a 'ref' formal of init=()
day18-bug3.chpl:26: called as Node.init(l: owned Node, r: owned Node)
day18-bug3.chpl:23: In function 'lineToTree':
day18-bug3.chpl:32: error: unresolved call '_new(type borrowed Node, owned Node?, owned Node?)'
day18-bug3.chpl:11: note: this candidate did not match: _new(type chpl_t, l: owned Node, r: owned Node)
day18-bug3.chpl:32: note: because actual argument #2 with type 'owned Node?'
day18-bug3.chpl:11: note: is passed to formal 'l: owned Node'
day18-bug3.chpl:32: note: try to apply the postfix ! operator to actual argument #2