Bug 16670 – std.variant visiting allows type parameters not held by variant

Status
RESOLVED
Resolution
WORKSFORME
Severity
minor
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2016-11-08T11:48:46Z
Last change time
2019-12-23T09:42:11Z
Keywords
pull
Assigned to
Nick Treleaven
Creator
Nick Treleaven

Comments

Comment #0 by nick — 2016-11-08T11:48:46Z
Algebraic!(size_t, string) variant; variant.visit!((void*)=>0, (size_t s)=>0, (string s)=>0); variant.tryVisit!((void*)=>0); variant.tryVisit!((bool)=>0); None of the 3 visiting functions should compile because `variant` can't hold void* or bool. Should be statically prevented to catch bugs.
Comment #1 by nick — 2016-11-08T18:59:01Z
I have a fix working locally, will submit a PR soon.
Comment #2 by bugzilla — 2019-12-23T09:42:11Z
When trying this I get errors for all three lines, so I assume, this has been fixed meanwhile.