[Issue 9681] New: std.variant.Algebraic with const members
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Mar 10 07:13:31 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9681
Summary: std.variant.Algebraic with const members
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: accepts-invalid
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2013-03-10 07:13:30 PDT ---
This code compiles with dmd 2.063alpha:
import std.variant: Algebraic;
struct A {}
alias Foo = Algebraic!(A);
void main() {
const A bar;
auto spam = Foo(bar); // line 6.
assert(spam.peek!(const A)); // No assertion failure
assert(spam.peek!A); // Assertion failure
}
And at runtime it asserts at line 8:
core.exception.AssertError at test2(8): Assertion failure
I think that maybe line 6 should be refused, otherwise it becomes hard to catch
all possible things that can be inside "spam". In this program bar is like an
Algebraic!(A, const A).
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list