On Thursday, 5 December 2019 at 12:00:23 UTC, Ola Fosheim Grøstad wrote:
So basically, templated functions get flow-typing.

But it is not reliable :-(

struct node {int value; node* next;}

node n0 = {1,null};

node mk_node1()(node* n){
    node tmp = {2019, n};
    return tmp;
}


node mk_node2()(bool ok){
    node tmp = {2019, ok ? null : &n0};
    return tmp;
}

void main() {
    immutable y = mk_node1(null); //succeeds
        immutable x = mk_node2(true); //fails
}


Reply via email to