Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
March 22, 2021 [Issue 21748] Return value of forward-referenced auto ref function mistakenly treated as lvalue | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21748 Paul Backus <snarwin+bugzilla@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid -- |
March 28, 2021 [Issue 21748] Return value of forward-referenced auto ref function mistakenly treated as lvalue | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21748 uplink.coder@googlemail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |uplink.coder@googlemail.com --- Comment #1 from uplink.coder@googlemail.com --- I can add a bit of detail. The issue here is the determination of auto-ref. Generally the ref-ness of a function-type does not depend on the body of the function. auto ref being the exception. When an auto ref function is encountered without having gone through the semantic3 to flag isRef is set to true. Therefore if main goes through semantic3 first, and it checks the type of fun, it will see that fun returns ref. If fun() is first, it will resolve the auto-ref to be non-ref. and set the isRef of it's type to false. Causing the isLvalue check to fail. -- |
March 28, 2021 [Issue 21748] Return value of forward-referenced auto ref function mistakenly treated as lvalue | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21748 uplink.coder@googlemail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|nobody@puremagic.com |uplink.coder@googlemail.com --- Comment #2 from uplink.coder@googlemail.com --- I can add a bit of detail. The issue here is the determination of auto-ref. Generally the ref-ness of a function-type does not depend on the body of the function. auto ref being the exception. When an auto ref function is encountered without having gone through the semantic3 to flag isRef is set to true. Therefore if main goes through semantic3 first, and it checks the type of fun, it will see that fun returns ref. If fun() is first, it will resolve the auto-ref to be non-ref. and set the isRef of it's type to false. Causing the isLvalue check to fail. -- |
March 28, 2021 [Issue 21748] Return value of forward-referenced auto ref function mistakenly treated as lvalue | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21748 --- Comment #3 from uplink.coder@googlemail.com --- This diff would fix it in a hacky way! BUT that does not address the systemic issue that the ast is in unstable states depending on resolve ordering! --- a/src/dmd/expression.d +++ b/src/dmd/expression.d @@ -5081,6 +5081,24 @@ extern (C++) final class CallExp : UnaExp if (tb.ty == Tdelegate || tb.ty == Tpointer) tb = tb.nextOf(); auto tf = tb.isTypeFunction(); + + // the real ref-ness of the function might not be inferred yet + // therefore we need to get the function out if there is one + if (tf) + { + if (auto ve = e1.isVarExp()) + { + if (ve.var) + { + if (auto fd = ve.var.isFuncDeclaration()) + { + fd.functionSemantic(); + fd.functionSemantic3(); + } + } + } + } -- |
December 17, 2022 [Issue 21748] Return value of forward-referenced auto ref function mistakenly treated as lvalue | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21748 Iain Buclaw <ibuclaw@gdcproject.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P1 |P3 -- |
December 13 [Issue 21748] Return value of forward-referenced auto ref function mistakenly treated as lvalue | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=21748 --- Comment #4 from dlangBugzillaToGithub <robert.schadek@posteo.de> --- THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19893 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB -- |
Copyright © 1999-2021 by the D Language Foundation