| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
May 10, 2022 [Issue 23101] [std.sumtype] canMatch does not account ref | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23101 --- Comment #1 from João Lourenço <jlourenco5691@gmail.com> --- Because of this, when matching, `canMatch` will fail as it will test for a copy, and returning a reference of that value results in escaping it. -- | ||||
May 10, 2022 [Issue 23101] [std.sumtype] canMatch does not account ref | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23101 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> --- @iK4tsu created dlang/phobos pull request #8457 "Issue 23101 - [std.sumtype] canMatch does not account ref " fixing this issue: - fix(sumtype): template canMatch does not account for ref when matching The template `canMatch` does not account for `ref`. The template `valueTypes` stores all types of the member values and uses SumTypes's `get` function, which returns a `ref`. However, ref does not persist and the type is not sent to `canMatch` as a `ref`. Because of this, when matching, `canMatch` will fail as it will test for a copy, and returning a reference of that value results in escaping it. Fix Issue 23101 Signed-off-by: João Lourenço <jlourenco5691@gmail.com> https://github.com/dlang/phobos/pull/8457 -- | ||||
May 11, 2022 [Issue 23101] [std.sumtype] canMatch does not account ref | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23101 --- Comment #3 from João Lourenço <jlourenco5691@gmail.com> --- Sorry, correction of the bug report example: ``` SumType!(int, string) st; st.match!( function int*(string _) => assert(0), function int*(ref int i) => &i, ); ``` -- | ||||
May 12, 2022 [Issue 23101] [std.sumtype] canMatch does not account ref | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23101 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> --- dlang/phobos pull request #8457 "Issue 23101 - [std.sumtype] canMatch does not account ref " was merged into master: - 6069c449303e8571b7b73c4fe50fc3088832d5fe by João Lourenço: fix(sumtype): template canMatch does not account for ref when matching The template `canMatch` does not account for `ref`. The template `valueTypes` stores all types of the member values and uses SumTypes's `get` function, which returns a `ref`. However, ref does not persist and the type is not sent to `canMatch` as a `ref`. Because of this, when matching, `canMatch` will fail as it will test for a copy, and returning a reference of that value results in escaping it. Fix Issue 23101 Signed-off-by: João Lourenço <jlourenco5691@gmail.com> https://github.com/dlang/phobos/pull/8457 -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply